0xFF != '\xFF' ?

Geoffrey Rogers grogers at convex.com
Wed Apr 10 13:39:10 AEST 1991


In article <28007837.35A9 at marob.uucp> daveh at marob.uucp (Dave Hammond) writes:
>In the following code examples, the '\nnn' representation causes the
>compiler to sign-extend 8 bit values, causing comparisons to fail (255
>!= -1).  This occurred on every machine I tested (Generic 386, Altos
>386, DEC uVax).  Is this because the '\nnn' token being seen as a char
>value and chars are signed on the machines I tested on?  

Yes, this is correct. This is because char's can be either signed or
unsigned. On the machines you mention, char is signed.

>Or must I expect this result from all C compilers?

No.

+------------------------------------+---------------------------------+
| Geoffrey C. Rogers   		     | "Whose brain did you get?"      |
| grogers at convex.com                 | "Abbie Normal!"                 |
| {sun,uunet,uiucdcs}!convex!grogers |                                 |
+------------------------------------+---------------------------------+



More information about the Comp.lang.c mailing list