3 ms·
vs int (*mat)[3] = calloc(3, sizeof(int[3])); which is a pointer to (or array of) arrays of 3 ints. Laid out flat, and you still get the `mat[i][j]` notat
by bruce343434 4y ago
vs
int (*mat)[3] = calloc(3, sizeof(int[3]));
which is a pointer to (or array of) arrays of 3 ints. Laid out flat, and you still get the `mat[i][j]` notation.
- rocqua 4y agoThat is indeed almost the same as int mat[3][3] The biggest reason people use the separate array of pointers is for very quick row swaps. Often comes up in matrix operations when trying to solve systems or put matrices in triangular forms.