fork download
  1. #include <stdio.h>
  2.  
  3. const int ROWS = 5;
  4. const int COLS = 4;
  5.  
  6. void printMatrix(int **matrix, int rows, int cols);
  7.  
  8. int main(void) {
  9. int matrix[ROWS][COLS];
  10. int i = 0;
  11.  
  12. for (int y = 0; y < ROWS; y++) {
  13. for (int x = 0; x < COLS; x++) {
  14. matrix[y][x] = ++i;
  15. }
  16. }
  17.  
  18. printMatrix(&matrix, ROWS, COLS);
  19.  
  20. return 0;
  21. }
  22.  
  23. void printMatrix(int **matrix, int rows, int cols) {
  24. for (int y = 0; y < ROWS; y++) {
  25. for (int x = 0; x < COLS; x++) {
  26. printf("%d\t", matrix[y][x]);
  27. }
  28.  
  29. printf("\n");
  30. }
  31. }
Runtime error #stdin #stdout 0s 5440KB
stdin
Standard input is empty
stdout
Standard output is empty