fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void swap(char *p, char *q) {
  5. char temp[5];
  6. memcpy(temp, p, sizeof(temp));
  7. memcpy(p, q, sizeof(temp));
  8. memcpy(q, temp, sizeof(temp));
  9. }
  10.  
  11. int main(void) {
  12. char str[5][5] = {
  13. {'E', 'D', 'C', 'B', 'A'}
  14. , {'F', 'G', 'H', 'I', 'J'}
  15. , {'O', 'N', 'M', 'L', 'K'}
  16. , {'P', 'Q', 'R', 'S', 'T'}
  17. , {'Y', 'X', 'W', 'V', 'U'}
  18. };
  19. for (int i = 0 ; i != 5 ; i++ ) {
  20. for (int j = 0; j != 5 ; j++)
  21. printf("%c ", str[i][j]);
  22. printf("\n");
  23. }
  24. printf("--------------\n");
  25. swap(str[0], str[3]);
  26. for (int i = 0 ; i != 5 ; i++ ) {
  27. for (int j = 0; j != 5 ; j++)
  28. printf("%c ", str[i][j]);
  29. printf("\n");
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
E D C B A 
F G H I J 
O N M L K 
P Q R S T 
Y X W V U 
--------------
P Q R S T 
F G H I J 
O N M L K 
E D C B A 
Y X W V U