例子:cuishenghui
反转后:iuhgnehsiuc
#include <iostream>
#include<string>
using namespace std;
void reverse_myString(char* str)
{
char*p = str;
int i = 0;
while (*p!= '\0')//要加*没有加*的话就读不出‘\0'这个字符
{
p++;
i++;//记录字母的个数
}
p--;
for (int j = 0; j <= i; j++, p--)
{
cout << *p;
}
}
int main()
{
char*str = "cuishenghui";
reverse_myString(str);
//cout << str;
system("pause");
return 0;
}