你先看清楚到底是c还是c++,不要混在一起说
换成英文名试试
#include<stdio.h>
#include<string.h>
/*
功能:反转字符串
参数1:目标字符串
返回值:新的字符串地址
*/
char *strInvert(char *Str1)
{
char *rtnChar;
char tmpChar;
rtnChar = Str1;
int length = strLength(Str1)-1;
int mid = length/2;
int index=0;
for(index=0;index<mid;index++,length--)
{
tmpChar = *(Str1+index);
*(Str1+index)=*(Str1+length);
*(Str1+length) = tmpChar;
}
return rtnChar;
}
int main()
{
char StrSrc[20] = "sunyunpeng";
printf("原有字符串为:%s\n", StrSrc); //sunyunpeng
printf("经过反转后字符串为:%s\n",strInvert(StrSrc)); //gnepnuynus
return 0;
}