Quote:
Originally posted by Ian W.
3) Is a -1 in a char varaible the same as a 255? I've been testing my code, and when I want a 255 to come up, a -1 comes up instead. I think they're the same, but once again, i'd like to check this out, because this may be causing errors to my program.
|
For a byte (which is what a char is), -1 is the same as 255, they are both stored as 0xFF in memory. If you print the variable out as a signed number (%d), it will be -1, if you print it out as an unsigned number (%u), it will be 255.
Mike