home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18742 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.3 KB

  1. Path: sparky!uunet!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec21.170917.17770@thunder.mcrcim.mcgill.edu>
  6. Date: 21 Dec 92 17:09:17 GMT
  7. References: <1992Dec12.111409.147@ondec.lonestar.org> <mcdonald.622@aries.scs.uiuc.edu>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 25
  10.  
  11. In article <mcdonald.622@aries.scs.uiuc.edu>, mcdonald@aries.scs.uiuc.edu (J. D. McDonald) writes:
  12. > In article <1992Dec18.182206.29158@mksol.dseg.ti.com> mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
  13.  
  14. >>>  4["this is a test"]
  15. >> We all know what the type and value is (well it's if type char and
  16. >> has value ' ' for those who don't know)
  17.  
  18. > Well, it has value ' '.
  19.  
  20. > But is it type char??
  21.  
  22. Yes.
  23.  
  24. > If it is an expression, it **can't** have type char, because any
  25. > expression promotes type char to type int.
  26.  
  27. If it is used in an rvalue context, yes, it gets promoted to int
  28. immediately.  But there are a few contexts where this doesn't happen,
  29. such as when it's an operand of sizeof.  sizeof(4["this is a test"])
  30. must produce 1, or your compiler's broken.
  31.  
  32.                     der Mouse
  33.  
  34.                 mouse@larry.mcrcim.mcgill.edu
  35.