试试:
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char a[50];
memset(a,0,sizeof(a));
int i=0,j;
char t;
cout<<"please input the string:\n";
cin.getline(a,50,'\n');
for(i=0,j=strlen(a)-1;i<strlen(a)/2;i++,j--)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
cout<<a<<endl;
system("pause");
return 0;
}