partially initialized array

1
2
3
4
5
6
7
8
9
10
#include<stdio.h>
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
getchar();
}

i am getting the value of *p as a garbage value..but i have read it somewhere that if you initialize an array partially,uninitialized elements are initialized to zero.....so why not in this case???
Unitialized elements ( in this case ) will be whatever value resided there in memory prior to allocation.
but what's wrong in what i have said that if an array is initialized partially,then remaining elements are automatically initialized to zero....i can support my explanation with an example
Topic archived. No new replies allowed.