[geeks] stupid C question

S. Gwizdak wazm at rm-f.net
Wed Feb 27 22:06:39 CST 2002


> Who had the bright idea to make the char type signed?  I just spend hours
> banging my head over a bug in my tga loader because I didn't remeber to make
> by chars unsigned.

A char is a single byte made to hold one character in the local character
set. On most machines, a byte is 8 bits. Two's complement notation gives 
the range of a single byte to be values of -128 to 127. An unsigned char
changes this value to 0-255. K&R2 states whether plain chars are signed
or unsigned is machine-dependent. 



More information about the geeks mailing list