Wednesday 5 December 2012

ANSWER

#include main() 
{ i
nt 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); } 

ANSWER
some garbage value---10
EXPLANATION

In this 3 dimensional array maximum index value are 1.

EXPRESSION &p[2][2][2] addresses the element far beyond the array area.
IT IS A PROGRAMMERS ERROR,although the compiler doesnot check it.The system may indicate it as general protection error.
***a is just first element  of the array (type int),but *q is deferencing uninitialised pointer,the value  would be stored in some random memory cell,which is the second serious error of the same type:memory allocation.

No comments:

Post a Comment