#include<stdio.h>
int main()
{
char c= 0xf1;
unsigned char uc= 0xf1;
printf(”c= %c\n", c);
printf(”uc= %c\n", uc);
if(c== uc) printf("Same\n");
else printf("NotSame\n");
return0;
}
c and cu have same binary presentation as char. But when comparison operation is performed, they are converted into int. c is presenting 1111 0001 (-15), uc is presenting 1111 0001 (241). So they are not same.
$./ex3
c= ?
uc= ?
NotSame
c= -15
uc= 241