fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. int myArray[3][8] =
  7. {
  8. { 3, 5, 7, 9, 11, 13, 15, 17 },
  9. { 8, 7, 6, 5, 4, 3, 2, 1 },
  10. { 2, 4, 6, 8, 10, 12, 14, 16 }
  11. };
  12.  
  13. // Switch data from index 2 from index 0 (of the 1D part of the array)
  14. int bkup[8] = { 0 };
  15. memcpy(bkup, myArray[0], sizeof(myArray[0]));
  16. memcpy(myArray[0], myArray[2], sizeof(myArray[2]));
  17. memcpy(myArray[2], bkup, sizeof(bkup));
  18.  
  19. // Print array content to the screen
  20. for (int i = 0; i < 3; i++)
  21. {
  22. for (int j = 0; j < 8; j++)
  23. printf("%d ", myArray[i][j]);
  24. printf("\n");
  25. }
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
2 4 6 8 10 12 14 16 
8 7 6 5 4 3 2 1 
3 5 7 9 11 13 15 17