Malloc a 2D array in C [duplicate]

like this : int (*arr)[M] = malloc(sizeof(int[N][M]));

arr is pointer to int[M].

use like arr[0][M-1];

and free(arr);

Leave a Comment