Hi,
I need to create and eventually destroy a (square) 2-D array of ints; the way I am creating it is:
I'm using calloc instead of malloc because it's useful to have all the elements initialised to 0. Firstly, is this the best way to do it (NUM_ENTRIES will be about 80,000)? Secondly, how do you free up all the memory taken up by the matrix?
thanks very much for any help.
Graham.
I need to create and eventually destroy a (square) 2-D array of ints; the way I am creating it is:
Code:
int **matrix;
matrix=(int **)calloc(sizeof(int *) * NUM_ENTRIES, sizeof(int *));
for(i=0; i<NUM_ENTRIES; i++)
matrix[i]=(int *)calloc(sizeof(int) * NUM_ENTRIES, sizeof(int));
I'm using calloc instead of malloc because it's useful to have all the elements initialised to 0. Firstly, is this the best way to do it (NUM_ENTRIES will be about 80,000)? Secondly, how do you free up all the memory taken up by the matrix?
thanks very much for any help.
Graham.