Why unsigned chars not default?

Grado mendozag at pur-ee.UUCP
Fri Oct 21 17:08:15 AEST 1988


  A guy around here is trying to port to several machines a program he
 hacked away in a PC using Lattice C.  For some obscure reason in his
 original program he decided to use only low-level I/O. That forced 
 him to "split" integers and then save them as 2 bytes and then later
 when the file is read back the integers are put together(!). 

  However, much to his dismay, other compilers (LSC, MSC, and Unix)
 require him to declare as unsigned char the I/O buffer (which he
 also uses for arithmetic operations) else the chars are negative
 numbers when the their contents represents value > 127. (He does
 a lot of arithmetic with characters representing integers).

   He claims the compilers are at fault and that all the compilers
 should have 'unsigned char' as default for characters so you
 can do all sorts of arithmetic with them.
 Any comments and/or suggestions I can pass along?
 [He basically learned C while developing this program and now has
  the chance of porting it to other machines, with copyright and all!].


 mendozag at ecn.purdue.edu



More information about the Comp.lang.c mailing list