*(s+2)
points to the "subarray" {5,6}
, whose first element is 5
:
*(s+0) ---> {1,2},
*(s+1) ---> {3,4},
*(s+2) ---> {5,6},
*(s+3) ---> {7,8}
So, to get the value pointed-to from the pointer, you have to insert another "*
", to deference one more time the pointer. This should work:
/* Dereference s+2 two times, to get the value 5: */
printf("%d\n",*(*(s+2)));
You can think of it in this way.
*(s+2)
is a pointer to the subarray {5,6}
.
Introduce a new intermediate variable int * a
, equal to *(s+2)
.
Now a
is a (simple, one-level-of-indirection) pointer to the array {5,6}
, actually to the first element of this array.
If you want the value 5
, you have to dereference the pointer, using *a
(just like you do for ordinary pointers and one-dimensional arrays).
Now if you substitute a
with *(s+2)
, *a
becomes *(*(s+2))
(a double-dereference from s
).