#include #include void f(int *p, int nrows, int ncols); main() { int a1[][3] = { {0, 1, 2}, {3, 4, 5} }; #define A1_ROWS (sizeof a1 / sizeof a1[0]) int a2[][5] = { { 2, 3, 5, 7, 11}, {13, 17, 19, 23, 29}, {31, 37, 41, 43, 47}, {51, 53, 57, 61, 67} }; #define A2_ROWS (sizeof a2 / sizeof a2[0]) f(&a1[0][0], A1_ROWS, 3); printf("\n"); f(&a2[0][0], A2_ROWS, 5); } void f(int *p, int nrows, int ncols) { int row; int col; for (row = 0; row < nrows; ++row) { printf("row %2d: ", row); for (col = 0; col < ncols; ++col) { printf("%2d", p[ncols * row + col]); if (col < ncols - 1) { printf(" "); } } printf("\n"); } }