M
Mike H
From the C Faq:
'You can keep the array's contents contiguous, while making later
reallocation of individual rows difficult, with a bit of explicit pointer
arithmetic:
'
' int **array2 = malloc(nrows * sizeof(int *));
' array2[0] = malloc(nrows * ncolumns * sizeof(int));
' for(i = 1; i < nrows; i++)
' array2 = array2[0] + i * ncolumns;
I know this should be obvious, but could someone show an example of how this
would be extended to 3 dimensions?
Thanks,
Mike H.
'You can keep the array's contents contiguous, while making later
reallocation of individual rows difficult, with a bit of explicit pointer
arithmetic:
'
' int **array2 = malloc(nrows * sizeof(int *));
' array2[0] = malloc(nrows * ncolumns * sizeof(int));
' for(i = 1; i < nrows; i++)
' array2 = array2[0] + i * ncolumns;
I know this should be obvious, but could someone show an example of how this
would be extended to 3 dimensions?
Thanks,
Mike H.