This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

comparing signed and unsigned variables

In the following code:-

char a = 0x80;
unsigned char b = 0x80;

if(a==0x80)
        printf("a==0x80\n");

if(b==0x80)
	printf("b==0x80\n");
The first printf isn't executed but the second is. Why is this? What is the correct way to compare signed variables?
I did think that this might be because the constant was an integer but a=='\x80' produces the same result.

TIA

Paul

0