字符串反转-C++

一、代码

 1 //字符串反转
 2 #include <iostream>
 3 using namespace std;
 4 void mystrrev(char string[])
 5 {
 6     int len=strlen(string);//判断字符串长度
 7     cout<<"输入的字符串长度为:"<<len<<endl;
 8     for (int i=len-1;i>=0;i--)
 9     {
10         cout<<string[i];
11     }
12     cout<<endl;
13 }
14 void main()
15 {
16     cout<<"请输入字符串:"<<endl;
17     char a[20];
18     cin>>a;
19     mystrrev(a);
20 }

二、演示

原文地址:https://www.cnblogs.com/f59130/p/3328540.html