标签:字符串逆序
#include <iostream>
using namespace std;
char* reset(char *pa)
{
if(pa == NULL)
{
return NULL;
}
else
{
char temp;
char *pch = pa;
while(*pch != ‘\0‘)
{
pch++;
}
pch--;
char *pb = pa;
while(pb != pch)
{
temp = *pch;
*pch = *pb;
*pb = temp;
pb++;
pch--;
}
}
return pa;
}
int main()
{
char str[] = "hello";
char* pch = reset(str);
cout<<str<<endl;
cout<<pch<<endl;
return 0;
}
标签:字符串逆序
原文地址:http://kiakel.blog.51cto.com/7134349/1582527