char buff[] = {1, 2, 3, 4};
short *ptr = (short *) buff;
ptr++;
printf("%d", *ptr);

Ans: 1027

Calculation:
Short pointer increments by sizeof(short) i.e. 2 bytes. Thus after increment, the pointer will point to &buff[2]; Lower byte is 3. Upper byte is 4. Hex value becomes 0x0403.
Thus the Value: (4 * 256) + 3 = 1027.

About our authors: Team EQA

You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.

#