I ran into a very strange problem. I think I am missing some very basic thing here. When I do this:
char buffer[1] = {0xA0};
int value=0;
value = (int)buffer[0];
printf("Array : %d\n",value);
I get result as -96, which shouldnt happen. It should give me 160, as hexa number 0xA0 means 160 in decimal. When I put small values in buffer like 0x1F, it works fine.
Can anyone tell me what am I missing here?
charis signed -128 to 127Declare
bufferasunsigned charor cast tounsigned char: