   Buffer overflow[SOLVED]
  With a simple statement such as:unsigned char foo = 0xFF;foo later evaluates to -1, throwing off my calculations. Can anyone explain why?EDIT: I forgot to change %d to %u. Ignore said post.   
  That would depend on the code involved when you try to evaluate it.   ;Quote:Original post by EctaraWith a simple statement such as:unsigned char foo = 0xFF;foo later evaluates to -1, throwing off my calculations. Can anyone explain why?EDIT: I forgot to change %d to %u. Ignore said post.You know, in C++ you could use operator>> overloads for I/O and avoid these kinds of problems automatically. Seeing as how you apparently care enough about type safety to bother with unsigned-type variables in the first place, you ought to use a type-safe I/O scheme as well. :)   ;  1) operator<<, not operator>>2) operator<< on a char type will output the char as a character not as an integer.   ;Quote:Original post by SiCrane1) operator<<, not operator>>2) operator<< on a char type will output the char as a character not as an integer.For some reason I must have been assuming the problem was with reading the value rather than displaying it, but then it wouldn't have behaved as described. :/   ;  Zahlman, what happened? Hangover? :)   