November 5th, 2012, 10:31 AM
dereferencing char pointers
why doesnt the following program work as expected:
imo, it should return "1", but it doesnt. It seems like instead of comparing 0xff == 0xff, the compiler compares 0xffffffff == 0xff. Why?
char x = 0xff;
char* y = &x;
if(*y == 0xff)
If i use "byte" for this example, everything works as expected, even though it`s just defined as an "unsigned char".
typedef unsigned char byte;
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!