Objective
Dynamically create an array of an array of Element strucs (defined below)
typedef struct {
void* data;
} Element;
Question
I know how to malloc an array of Element strucs
Element* arrayOfElements = malloc(4 * sizeof(Element));
But then how do I Malloc an array of the above? (an array of arrayOfElements)
Question 2
Lets say the array of arrayOfElements is called arrayOfArrayStruc how would I proceed to set values inside of it
For Example I want to copy 65 to arrayOfElements[2] which is inside arrayOfArrayStruc1 how would I got about that ?
I know how to do that if I wanted to copy 65 straight to arrayOfElements[2]
arrayOfElements[2].data = malloc( sizeof(int) );
ptr = arrayOfElements[2].data;
*ptr = 65;
but im not sure how to do that if arrayOfElements[2] is inside arrayOfArrayStruc1.
EDIT
To make it more clear my goal i've made a picture
So in green is the structure Element defined by
typedef struct {
void* data;
} Element;
Then in red ( which had 4 green boxes) is an Array of Element structures which I malloc'd using
Element* arrayOfElements = malloc(4 * sizeof(Element));
What im looking to do is store the above ^^ in an array or make an array of pointers (which is the blue box with red boxes in it)
So in the picture "Array Of Element" holds 4 Element Structures, then I want to make an array to store 4 "Array Of Element" (or an array of 4 pointers to point to each "Array of Element")

structs you can write your "array" as a structure and have an array of that.arrayOfElements, then that does not contain the green elements. The green elements are in their own block, and the pointer points to it. An array contains its elements , a pointer is a separate thing to an array, and it points to the first element of an array.