1 #include <stdio.h>
2
3 void print_2d_array(int rows, int cols, int *a) {
4 for(int i = 0; i < rows; ++i) {
5 for(int j = 0; j < cols; ++j) {
6 printf("%d ", a[i * cols + j]);
7 }
8 printf("
");
9 }
10 }
11
12 int main(void) {
13 int arr[][3] = {
14 {1, 2, 3},
15 {4, 5, 6}
16 };
17
18 print_2d_array(2, 3, arr[0]);
19 }