I tried the following program in RHEL 4 and got some unexpected results
main()
{
int a[2][2][2]={{15,2,3,4},{5,6,7,8}};
int *p,*q;
*q=***a;
printf("\n%d\n",*q);
printf("\n\n\n");
printf("%p a[0][0][0] %2d\n%p a[0][0][1] %2d\n%p a[0][1][0] %2d\n%p a[0][1][1] %2d\n%p a[1][0][0] %2d\n%p a[1][0][1] %2d\n%p a[1][1][0] %2d\n%p a[1][1][1] %2d\n",&a[0][0][0],a[0][0][0],&a[0][0][1],a[0][0][1],&a[0][1][0],a[0][1][0],&a[0][1][1],a[0][1][1],&a[1][0][0],a[1][0][0],&a[1][0][1],a[1][0][1],&a[1][1][0],a[1][1][0],&a[1][1][1],a[1][1][1]);
printf("\n\n\n");
}
When i print the array the value pointed by q gets printed as the third element.
Can any one please help
main()
{
int a[2][2][2]={{15,2,3,4},{5,6,7,8}};
int *p,*q;
*q=***a;
printf("\n%d\n",*q);
printf("\n\n\n");
printf("%p a[0][0][0] %2d\n%p a[0][0][1] %2d\n%p a[0][1][0] %2d\n%p a[0][1][1] %2d\n%p a[1][0][0] %2d\n%p a[1][0][1] %2d\n%p a[1][1][0] %2d\n%p a[1][1][1] %2d\n",&a[0][0][0],a[0][0][0],&a[0][0][1],a[0][0][1],&a[0][1][0],a[0][1][0],&a[0][1][1],a[0][1][1],&a[1][0][0],a[1][0][0],&a[1][0][1],a[1][0][1],&a[1][1][0],a[1][1][0],&a[1][1][1],a[1][1][1]);
printf("\n\n\n");
}
When i print the array the value pointed by q gets printed as the third element.
Can any one please help
