Tuesday, September 1, 2009

About Pointer Address

Hi to all,
Welcome to all of you.

First problem-
#include
int main()
{
int arr[2][3][4];
printf ("%u..%u..%u..%u", arr,&arr,arr+1,&arr+1);
return 0;
}
......the question is what is the output, and whats the logic behind that output.

1 comment:

Abhinav Mehta said...

the answer will be...
65478...65478...65502...65526

The first two results are quite predicted as they are denoting to some base address to the array, and about the third one...observe carefully,
the array is 3D, so the denotion will be something like [x][x][x], now if we just do the a+1, it will increment the first index of the 3D array, i.e. [x+1][x][x], thats the reason for 3rd output.....and for 4th output, its printing the last element of the array, thats base+48, for that i also dont know, whats the logic behind.