edited by
482 views

1 Answer

1 votes
1 votes
hello. Its a very nice and conceptual question. Now see char * has the size just half of that of int, the number of bytes depends upon your machine.

So the pointer p(char) stores the address of x(int), but the memory length of int is 16 bits , but char will point to its first 8 bits.

Now the binary representation of 191 is as follows(16 bit):

191=  00000000   1011111

           (last 8 bits)(first 8 bits)

so the char pointer points to the first 8 bits. And the answer  will be the 2S complement form in decimal of the first 8 bits that is -65.

NOTE: YOU CAN CHECK BY GIVING AN EXTRA printf() AND WITH *(p+1) and you will get the decimal part of the last 8 bits i.e. 0.

Related questions

2 votes
2 votes
2 answers
1
go_editor asked Jun 13, 2016
4,277 views
In C, what is the effect of a negative number in a field width specifier?the values are displayed right justifiedthe values are displayed centeredthe values are displayed...
1 votes
1 votes
4 answers
2
Jonathan Decosta asked Jul 6, 2015
599 views
int main() { int i = 255; char *p; p = &i; printf("%d", *p); return 0; }
3 votes
3 votes
1 answer
4