# Thread: Make an array of arrays

1. ## Make an array of arrays

Hi, I'm writing C code for a project and I would like to know (if it's possible) how to make an array of arrays. I mean I want to place a bidimensional array inside each one of the elements of an unidimensional array.

2. 1D integer array: int array1d[10];
access via: array1d[index];

2D integer array: int array2d[10][10];
access via: array2d[indexY][indexX];

3D integer array: int array3d[10][10][10];
access via: array3d[inxexZ][indexY][indexX];

Etc.

3. It is a bit more complicated if you want a fairly big array, which isn't uncommon for 3D arrays. In that case you will need to dynamically allocate memory, because statically allocated memory can overflow the stack. An example is Z, X, Y being > 1000.

Do that like this for a Z*Y*X 3d-array:
Code:
```int ***array;
for (int z = 0; z < Z; ++z) {
array[z] = malloc(Y *  sizeof(*int));
for (int y = 0; y < Y; ++y)
array[z][y] = malloc (X * sizeof(int));
}```
and access normally with array[z][y][x];

(though I believe there is a bit better solution, which kind of bored to think atm)

4. Code:
`T (*array)[3d_size][2d_size] = malloc(1d_size * 2d_size * 3d_size * sizeof(T));`