fork download
  1. #include <stdio.h>
  2.  
  3. void copyMatrix(int (*dst)[3], int (*src)[3], int rows) {
  4. for (int i = 0; i < rows; i++)
  5. for (int j = 0; j < 3; j++)
  6. dst[i][j] = src[i][j];
  7. }
  8.  
  9. int main(void) {
  10. int a[2][3] = {{1, 2, 3}, {4, 5, 6}};
  11. int b[2][3] = {0};
  12.  
  13. copyMatrix(b, a, 2);
  14.  
  15. for (int i = 0; i < 2; i++) {
  16. for (int j = 0; j < 3; j++) {
  17. printf("%d ", b[i][j]);
  18. }
  19. printf("\n");
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
1 2 3 
4 5 6