*(num+1)[1]
and**(num+2)
are different ways of writing the same thing. That is, the third element ofnum
.- The type of
num
isshort (*)[2]
. That is, it is a pointer to an array of 2short
values.
With these two facts in mind we can work out what the code is doing. Below assumes a 32 bit system for simplicity.
num+1
. Sincenum
points to twoshort
values, using pointer arithmetic,num+1
will be 4 bytes (2 shorts) afternum
.(num+1)[1]
. The array index gives the second element starting fromnum+1
. That means another 4 bytes pastnum+1
and hence 8 bytes pastnum
.- Accessing 8 bytes after
num
gives exactly15
.
0
solved Advance Programming in c