fork download
  1. #include <stdio.h>
  2. void print(int *arr, int m, int n)
  3. {
  4. int i, j;
  5. for (i = 0; i < m; i++)
  6. for (j = 0; j < n; j++)
  7. printf("%d ", *((arr+i*n)+j));
  8. }
  9.  
  10. int main()
  11. {
  12. int arr[][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  13. int m = 3, n = 3;
  14.  
  15. // We can also use "print(&arr[0][0], m, n);"
  16. print((int *)arr, m, n);
  17. return 0;
  18. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 7 8 9