+ 1

The output is 55, but I don't understand why the memory address of the *ptr is 23fe3c.

#include <stdio.h> int main() { int a[5] = {22, 33, 44, 55, 66}; int *ptr = NULL; ptr = a; /* point to the first array element */ ptr += 3; printf("%d %x\n", *ptr, ptr); /* 55 */ } /*The output is 55, but I don't understand why the memory address of the *ptr is 23fe3c. Here's the output for different values of an increment: (no increment) is 23fe30 (22) ptr++ is 23fe34 (33) ptr += 2 is 23fe38 (44) ptr += 3 is 23fe3c (55) <--Where I confuse. Why "c"? ptr += 4 is 23fe40 (66) */

30th Dec 2018, 1:43 PM
Konybud
Konybud - avatar
2 Answers
+ 1
How about 23fe40. How can it go from 23fe3c to that number.
30th Dec 2018, 2:07 PM
Konybud
Konybud - avatar
+ 1
How...
30th Dec 2018, 2:15 PM
Konybud
Konybud - avatar