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
]);
39 void foo3(int **mat
, int rows
, int cols
)
43 for (i
= 0; i
< rows
; i
++) {
44 for (j
= 0; j
< cols
; j
++)
45 printf("%d ", *((int *)mat
+ cols
* i
) + j
);
52 int mat
[4][3] = { { 1, 2, 3},
57 foo3((int **)&mat
[0][0], 4, 3);
58 foo2((int **)&mat
[0][0], 4, 3);
59 /* foo1((int **)&mat[0][0], 4, 3); */