NH> Given the following code:
NH> void
NH> foo(void)
NH> {
NH> unsigned char foo = 'z';
NH> foo = foo >> 3; /* warning on this line */
NH> }
NH> The warning I receive is that the line of code above involves
NH> "conversion between integral types". However, if I write the
NH> offending line as:
NH> foo = (unsigned char)(foo >> 3);
NH> I don't receive the warning messages. Why is this?
Because you are now EXPLICITLY converting between unsigned int and unsigned
char (a lossy conversion).
The >> and << operators work on ints, not chars.
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|