home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.18 / text0014.txt < prev    next >
Encoding:
Internet Message Format  |  1990-03-18  |  1.0 KB

  1. From: bill@twwells.com (T. William Wells)
  2.  
  3. In article <498@longway.TIC.COM> uunet!stealth.acf.nyu.edu!brnstnd (Dan Bernstein) writes:
  4. : From: brnstnd@stealth.acf.nyu.edu
  5. :
  6. : The question is self-explanatory. This is a practical question as well
  7. : as a theoretical one: I'd like a solution that is both conformant and
  8. : portable in the real world. Does (int) (unsigned int) ch do the trick?
  9. : What about (int) (unsigned char)?
  10.  
  11. Excuse, but this is purely a C question, so I've directed
  12. followups to comp.lang.c.
  13.  
  14. [ I'm not sure I agree, but I don't see comp.std.unix people clamoring
  15. to answer this question, so let's send it to comp.lang.c to see if there
  16. is more interest there.  -mod ]
  17.  
  18.  Anyway, I don't think that either is
  19. guaranteed. One that is, assuming that the character is not in a
  20. register, is: *(unsigned char *)&ch.
  21.  
  22. (NB: a char might be converted to a number larger than 255 if
  23. characters are larger than eight bits.)
  24.  
  25. ---
  26. Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
  27. bill@twwells.com
  28.  
  29. Volume-Number: Volume 18, Number 15
  30.  
  31.