I am confused by the following code:
char c = 0x66;
printf("~c = %x\n", ~c); //0xffffff99
printf("size of c: %d\n", sizeof(c)); //1 byte
printf("Size of ~c: %d\n", sizeof(~c)); //4 bytes
A char
only has 1 byte but the result will be 4 bytes using the ~
operator. Why is the result of ~c
0xffffff99
rather than 0x99
?
Are there some mistakes I have made?