Ok, so I'm learning pointers and I am having trouble understanding how the pointers function in arrays.
Basically given this:
int a[5] = {1,2,4,7,7}; // (allocated at 0xA000)
int b[5] = {4,3,5,1,8}; // (at 0xA0020)
short *c[2]; // (at 0xA0040)
c[0] = (short *)b;
c[1] = (short *)a;
I'm supposed to determine the values of these calculations.
c[0] + 4
To my understanding c
is an array of pointers. c[0]
is a short that holds the pointer to the first element of the array b
. If b
starts at 0xA0020
why is is that c[0] + 4
is not 0xA0024
and instead it is 0xA0028
.
Also, how am I supposed to determine the value of c[1][2]
. c
is not a multidimensional array, so how would this calculation work out?
Thank you!