In this piece of code, I noticed themalloc()
frees up memory of size of (double *)
and double
. So when the rest of the code is storing values in DataArray, how does the compiler know where to store those values in the memory?
int rows=100;
int columns=100;
double **DataArray, *DataRow;
DataArray = (double **)malloc(rows *sizeof(double *)+ rows * columns *sizeof(double));
for (i = 0, DataRow = (double *)(DataArray+rows); i < rows; i++, DataRow += columns)
DataArray[i]=DataRow;
Thank You!