For example for this line:
printf ("%d\n", *(*(p + 1) + 1));
Look at that line:
int *p[] = {*a, *(a + 1) , *(a + 2) };
So p
is pointer (array) to integer pointers with some address and value *a
at initial index.
Then (p + 1)
is next address of p
and its value *(p + 1)
is pointer *(a + 1)
Next, a
is two dimension array and (a + 1)
is array of addresses for values 6, 7, 8, 9, 10
Therefore *(p + 1)
is address for value 6 and *(p + 1) + 1
is address for value 7.
So we get: *(*(p + 1) + 1)
is integer value from address for value 7, i.e.
printf ("%d\n", *(*(p + 1) + 1));
returns 7
Try to figure out the rest of code. Same method.
solved How to get the output of this C program?