create 3 dimensional pointer array in c

Answer:

void main(){
static int *p,*q,*r,*s,*t,*u,*v;
int i=3,j=6,k=9,l=12,m=15,n=18,o=21;
int *ptr_arr[2][3][1];
int x,y,z,in=0;
int **arr[]={&p,&q,&r,&s,&t,&u,&v};
p=&i;q=&j;r=&k;s=&l;t=&m;u=&n;v=&o;
for(x=0;x<2 data-blogger-escaped-div="" data-blogger-escaped-x="">
for(y=0;y<3 data-blogger-escaped-div="" data-blogger-escaped-y="">
for(z=0;z<1 data-blogger-escaped-div="" data-blogger-escaped-z="">
ptr_arr[x][y][z]=*arr[in++];
}
}
}
clrscr();
for(x=0;x<2 data-blogger-escaped-div="" data-blogger-escaped-x="">
for(y=0;y<3 data-blogger-escaped-div="" data-blogger-escaped-y="">
for(z=0;z<1 data-blogger-escaped-div="" data-blogger-escaped-z="">
printf("%d ",*ptr_arr[x][y][z]);
}
}
}
getch();


}


Output: 3 6 9 12 15
Explanation: Here ptr_arr is 3 dimensional array of pointer to integers.

No comments: