I got the following code:
I am confused on this line: rptr = malloc(nrows * COLS * sizeof(int));Code:#define COLS 5 typedef int RowArray[COLS]; RowArray *rptr; int main(void) { int nrows = 10; int row, col; rptr = malloc(nrows * COLS * sizeof(int)); for (row = 0; row < nrows; row++) { for (col = 0; col < COLS; col++) { rptr[row][col] = 17; } } return 0; }
Wouldnt that just create a like a long memory storage space? How does the compiler know that it has rows and cols??
thanks



LinkBack URL
About LinkBacks



