Other contributors have said "How would you dynamically allocate a one-dimensional and two-dimensional array of integers?" is the same question as "How do you declare an N-Dimensional array using Malloc?" If you believe that these are not asking the same thing and should be answered differently, click here

How do you declare an N-Dimensional array using Malloc?

Answer:

Answer

#include <stdlib.h>
int **array1 = malloc(nrows * sizeof(int *));
for(i = 0; i < nrows; i++)
array1[i] = malloc(ncolumns * sizeof(int));
First answer by ID3418906498. Last edit by ID3418906498. Question popularity: 70 [recommend question].