fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.  
  7. void fx(char s[100]);
  8. char s[100];
  9. //int n;
  10.  
  11. printf("输入一串字符串:\n");
  12. scanf("%s",s);
  13. printf("输出的字符串:\n",s);
  14. // n=strlen(s);
  15. fx(s);
  16. printf("反转后的字符串为:%s\n",s);
  17. return 0;
  18. }
  19. void fx(char s[])
  20. {
  21. char t;
  22. int j=strlen(s);
  23. for(int i=0;i<j;i++)
  24. {
  25. t=s[i]; s[i]=s[j-i]; s[j-i]=t;
  26. }
  27. }
Success #stdin #stdout 0.01s 5304KB
stdin
abcdefg
stdout
输入一串字符串:
输出的字符串:
反转后的字符串为: