I want to declare Pointer ptr0
that points to array1 of pointers to arrays of pointers
that have elements of pointers that points to another arrays of pointers to arrays of integers
that consists of integer elements.
Note: Each array consist of three elements.
here is my approach:-
//C99
#include <stdio.h>
#include <stdlib.h>
int main()
{
/* Level 3 */
int arrays_int_3_1_1[3] = {0,1,2};
int arrays_int_3_1_2[3] = {3,4,5};
int arrays_int_3_1_3[3] = {6,7,8};
int arrays_int_3_2_1[3] = {9,10,11};
int arrays_int_3_2_2[3] = {12,13,14};
int arrays_int_3_2_3[3] = {15,16,17};
int arrays_int_3_3_1[3] = {18,19,20};
int arrays_int_3_3_2[3] = {21,22,23};
int arrays_int_3_3_3[3] = {24,25,26};
/* Level 2 */
void *arrays_2_1[3] = {(void*)arrays_int_3_1_1,(void*)arrays_int_3_1_2,(void*)arrays_int_3_1_3};
void *arrays_2_2[3] = {(void*)arrays_int_3_2_1,(void*)arrays_int_3_2_2,(void*)arrays_int_3_2_3};
void *arrays_2_3[3] = {(void*)arrays_int_3_3_1,(void*)arrays_int_3_3_2,(void*)arrays_int_3_3_3};
/* Level 1*/
void **array1[3] = {arrays_2_1,arrays_2_2,arrays_2_3};
/* Level 0*/
void ***ptr0 = array1;
/*-----------------------------*/
for (int i = 0 ; i <27 ; i++)
{
// Question here..
printf("%d \n", <??? How to do the dereference to access each element ???>);
}
}
Quesiton is >> How to do the dereference to access each element