home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18639 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.1 KB  |  53 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
  3. From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec18.181806.28952@mksol.dseg.ti.com>
  6. Organization: Texas Instruments Inc
  7. References: <rfries.150@sceng.ub.com> <rfries.151@sceng.ub.com> <1992Dec18.093717.7661@jussieu.fr> <BzGoGn.A93@cck.coventry.ac.uk>
  8. Date: Fri, 18 Dec 1992 18:18:06 GMT
  9. Lines: 42
  10.  
  11. In <BzGoGn.A93@cck.coventry.ac.uk> champion@cch.coventry.ac.uk (Alun) writes:
  12.  
  13. >In article <1992Dec18.093717.7661@jussieu.fr> fred@trot.ibp.fr (Frederic PETROT) writes:
  14. >~d_north@ondec.lonestar.org (David G. North, CCP) writes:
  15. >~>Or better yet, what is the type and value of the following expression:
  16. >~>  "this is a test"[4]
  17. >~
  18. >~try this one (due to a friend of mine):
  19. >~
  20. >~main()
  21. >~{
  22. >~   printf("%c", unix["abc"]);
  23. >~}
  24. >~
  25.  
  26. >Why does this print 'b' ??
  27. >I could understand the indexing with numbers but with [unix] ??
  28.  
  29. I would suspect that thec compiler in question does a '#define unix 1'
  30. to indicate to itself (and programs) that it is in a UNIX environment.
  31. So what you're really doing is indexing the [1] element of the  string
  32. "abc", which gets you the character 'b'.
  33.  
  34. >Please help a confused individual.
  35.  
  36. >I consider myself competent with the C and find it difficult to understand
  37. >why anyone would ask these type of questions in an interview - surely these
  38. >don't show someones level of competence.
  39.  
  40. I consider such quizes to be a waste of time in general, and quizes
  41. over 'tricks' to be even more worthless.
  42.  
  43. [I've always considered myself competent, but certainly no guru; yet I
  44. can answer pretty much all of these.  See what reading comp.lang.c and
  45. the FAQ for a long time will do for you?  Or should that be 'to you'?
  46. ;-)] 
  47.  
  48. -- 
  49. "Insisting on perfect safety is for people who don't have the balls to live
  50.  in the real world."   -- Mary Shafer, NASA Ames Dryden
  51. ------------------------------------------------------------------------------
  52. Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
  53.