fork download
  1. // The following program works only if your compiler is C99 compatible.
  2. #include <stdio.h>
  3.  
  4. // m and n must be passed before the 2D array
  5. void print(int m, int n, int arr[][n])
  6. {
  7. int i, j;
  8. for (i = 0; i < m; i++)
  9. for (j = 0; j < n; j++)
  10. printf("%d ", arr[i][j]);
  11. }
  12.  
  13. int main()
  14. {
  15. int arr[][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  16. int m = 3, n = 3;
  17. print(m, n, arr);
  18. return 0;
  19. }
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 7 8 9