0 votes 0 votes #include<stdio.h> int main() { int a[2][2][2]={10,2,3,4,5,6,7,8}; int *p,*q; p=&a[1][1][1]; q=(int*)a; //Please explain this line printf("%d%d"*p,*q); return 0; } Why we are doing typecasting here and what will be returned after type cast to q? Programming in C programming-in-c pointers + – junaid ahmad asked Dec 19, 2017 junaid ahmad 317 views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply joshi_nitish commented Dec 19, 2017 reply Follow Share 'a' is initially equivalent to triple dimensional pointer i.e ***a and p is single dimensional pointer i.e *p now if you want to perform p=a, you have to cast 'a' into single dimensional pointer, that is what (int*)a do. q=(int*)a; will simply make q to point to first element of array i.e '10', it is equivalent to q=&a[0]; 1 votes 1 votes Mk Utkarsh commented Dec 20, 2017 i edited by Mk Utkarsh Dec 20, 2017 reply Follow Share in this line q=(int*)a; q is storing the starting address of a hence *q will print 10 1 votes 1 votes junaid ahmad commented Dec 20, 2017 i edited by junaid ahmad Dec 20, 2017 reply Follow Share @joshi_nitish is it correct to say that,when normally when we do typecast like p=(int)a; it wil return value a,now here since it is given like p=(int *)a; this will return a pointer to pointer to a i.e currently p is refring to a[0][0]. 0 votes 0 votes Please log in or register to add a comment.