So a dynamic two-dimensional array using malloc would be this:
I think I have all the keywords, so that should show up on a search. Later you will have to do this:Code:int **two_d_array;
two_d_array = malloc(rows * sizeof(int *));
for (int i = 0; i < rows; i++) {
two_d_array[i] = malloc(columns * sizeof(int));
}
return two_d_array;
So make sure you keep hold of the pointer.Code:for (int i = 0; i < rows; i++) {
free(two_d_array[i]);
}
free(two_d_array);

