#include<stdio.h>
#include<iostream>
#include<cstring>
using namespace std;
/*
*Author: http://blog.youkuaiyun.com/godwin_q
*程序环境: C—Free5.0
*语言:C++
*功能:字符串逆序
*/
void ReverseOrder(char* s)
{
char temp;
int len = strlen(s);
for(int i = 0,j = len-1;i<j;i++,j--)
{
temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
int main()
{
char s[] = "123456";
cout << s << " 长度:" << strlen(s) << endl;
ReverseOrder(s);
cout << s << " 长度:" << strlen(s) << endl;
}
注意只能定义为char s[] = "123456"; 在堆栈区。