To create a dynamic array,we use malloc to dynamically allocate memory space:
#include <stdio.h>
#include <stdlib.h>
int main(void){
int i, j, col = 3, row = 4;
/* Creating Dynamic Two dimensional Array */
int **m = (int**)malloc(col * sizeof(int));
for(int i = 0; i < col ; i++){
m[i] = (int*)malloc(row * sizeof(int));
}
// the code using the array:
/*
code
*/
/* Releases the 2-dimensional array */
for (int i = 0; i < row; i++){
free(m[i]);
}
free(m);
}