Hi All,
> what should we do?
Start by writing good code ... pick your data type and stick with it.
The result of relational and equality operators is of type
int when the operands are
integral types ... so,
char and
unsigned char are promoted to type
int (the range of
both can be represented by an
int) ... and the sign is preserved (or "extended" into
the higher-order bits).
Basically, if (for whatever reason) bit 7 of your 8-bit data is
not a sign bit, then
don't treat it as such -- use
unsigned char instead (and ditto for
short and
unsigned short) ... you'll save yourself some headaches and you can use:
if(test_char==good)
with confidence.
Regards,
--Scott