Q
Hello,
Here is my simple program
int main()
{
unsigned char a =0x81;
char b = 0x81;
printf("unsigned char = 0x%x(%d), char = 0x%x(%d)\n",a,a,b,b);
printf("cast char to unsigned 0x%x\n",(unsigned char)b);
}
~
And here is the print out:
unsigned char = 0x81(129), char = 0xffffff81(-127)
cast char to unsigned 0x81
The result is what I expected, but I couldn't explain it well.
Could someone give me a help and explain to me what 0xfffff81.
(a char is one byte right?)
And is cast here good? if not, is there any other way I can print out a
char 0x81 as 0x81
printf("cast char to unsigned 0x%x\n",(unsigned char)b);
Thanks a lot!
Here is my simple program
int main()
{
unsigned char a =0x81;
char b = 0x81;
printf("unsigned char = 0x%x(%d), char = 0x%x(%d)\n",a,a,b,b);
printf("cast char to unsigned 0x%x\n",(unsigned char)b);
}
~
And here is the print out:
unsigned char = 0x81(129), char = 0xffffff81(-127)
cast char to unsigned 0x81
The result is what I expected, but I couldn't explain it well.
Could someone give me a help and explain to me what 0xfffff81.
(a char is one byte right?)
And is cast here good? if not, is there any other way I can print out a
char 0x81 as 0x81
printf("cast char to unsigned 0x%x\n",(unsigned char)b);
Thanks a lot!