fork(3) download
  1. #include <stdio.h>
  2. #include <memory>
  3.  
  4. int main() {
  5. const int nrows = 4, ncols = 5;
  6. const int dx = 2, dy = 1;
  7. int a[4][5] = { {1, 2, 3, 4, 5},
  8. { 6, 7, 8, 9, 10 },
  9. { 11, 12, 13, 14, 15 },
  10. { 16, 17, 18, 19, 20 }
  11. };
  12. int tmp[4][5];
  13. for (int i = 0; i < nrows; i++)
  14. for (int j = 0; j < ncols; j++)
  15. tmp[(i + dx) % nrows][(j + dy) % ncols] = a[i][j];
  16. memcpy(a, tmp, sizeof(tmp));
  17. for (int i = 0; i < nrows; i++)
  18. for (int j = 0; j < ncols; j++)
  19. printf(j < ncols - 1 ? "%3d " : "%3d\n", a[i][j]);
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:28: error: 'memcpy' was not declared in this scope
  memcpy(a, tmp, sizeof(tmp));
                            ^
stdout
Standard output is empty