Hey,
I'm a java programmer, and am quite new to C.
I know how to allocate memory dynamically for most things such as arrays and structures, but don't know how to (if it is possible at all) to allocate memory for a 2D array.
I tried something like the following but it doesn't work:
int** matrix;
.
.
.
matrix = (int**)malloc(sizeof(int) * numVertices * numVertices);
If anyone could help, it would be much appreciated.
Thanx
I'm a java programmer, and am quite new to C.
I know how to allocate memory dynamically for most things such as arrays and structures, but don't know how to (if it is possible at all) to allocate memory for a 2D array.
I tried something like the following but it doesn't work:
int** matrix;
.
.
.
matrix = (int**)malloc(sizeof(int) * numVertices * numVertices);
If anyone could help, it would be much appreciated.
Thanx