5 void foo1(int **mat
, int rows
, int cols
)
9 for (i
= 0; i
< rows
; i
++) {
10 for (j
= 0; j
< cols
; j
++)
11 printf("%d ", mat
[i
][j
]);
17 void foo2(int **mat
, int rows
, int cols
)
22 aux
= malloc(rows
* sizeof(int *));
28 for (i
= 0; i
< rows
; i
++) {
29 aux
[i
] = (int *)mat
+ cols
* i
;
30 for (j
= 0; j
< cols
; j
++)
31 printf("%d ", aux
[i
][j
]);
40 int mat
[4][3] = { { 1, 2, 3},
45 foo2((int **)&mat
[0][0], 4, 3);
46 foo1((int **)&mat
[0][0], 4, 3);