cmemory-managementmallocmultidimensional-array

Dynamic memory allocation for 3D array


Possible Duplicates:
Malloc a 3-Dimensional array in C?
dynamic allocation/deallocation of 2D & 3D arrays

How can i allocate 3D arrays using malloc?


Solution

  • array = malloc(num_elem * num_elem * num_elem * sizeof(array_elem));
    

    Why not? :)