fork download
  1. #include <stdio.h>
  2. #define STRSIZE 10
  3.  
  4. void swap_string(char s1[], char s2[]){
  5. int i;
  6. char tmp;
  7.  
  8. for (i = 0; i < STRSIZE; i++){
  9. /* 文字列 s1 と s2 の各文字を交換 */
  10. tmp = s1[i];
  11. s1[i] = s2[i];
  12. s2[i] = tmp;
  13. }
  14. }
  15.  
  16. int main(void){
  17. char str1[STRSIZE] = "ABC";
  18. char str2[STRSIZE] = "123";
  19.  
  20. swap_string(str1, str2);
  21.  
  22. printf("str1=%s, str2=%s\n", str1, str2);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
str1=123, str2=ABC