#include <stdio.h>
void print_array(int (*ptr)[5], int rows, int cols) {
int* p = (int*)ptr;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
printf("%d ", *(p + i * cols + j));
}
printf("\n");
}
}
int main(void)
{
int arr[4][5] = { { 5, 9, 3, 6, 8 },
{ 0 },
{ [2] = 99, 88 } };
int rows = (sizeof(arr) / sizeof(arr[0]));
int cols = (sizeof(arr) / sizeof(arr[0][0])) / rows;
print_array(arr, rows, cols);
return 0;
}
/*
run:
5 9 3 6 8
0 0 0 0 0
0 0 99 88 0
0 0 0 0 0
*/