int *q,a[10]={1,2,3,4,5,6,7,8,9,0};
char *p;
p=(char*)a;
p++;
q=(int*)p;
printf("\n%d",*q);
Please explain for me why display is 33554432
int *q,a[10]={1,2,3,4,5,6,7,8,9,0};
char *p;
p=(char*)a;
p++;
q=(int*)p;
printf("\n%d",*q);
Please explain for me why display is 33554432
Assuming we have 4-byte integers, stored in little-endian fashion (lowest byte first), the array is stored (in bytes) as:
01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 ...etc.
p
points to the second byte, and q
points to the integer starting at that same place, so:
00 00 00 02
since we're stored low-to-high, that integer is:
0x02000000
in hex, or 33554432
in decimal.