反序输出
写一函数,使输入的一个字符串按反序存放在一字符数组中,然后输出。除了用指针做以外,还可用什么方法呢?请赐教.......
#include <iostream>
using namespace std;
const int maxsize=50;
int count=0;
int main () {
char text[maxsize]={0};
cout<<endl<<"enter a line of text:"<<endl;
cin.getline(text,maxsize);
cout<<"you entered:"<<endl<<text<<endl;
cout<<"opposite output is:";
count=maxsize-1;
for(int i=count;i>=0;--i){
cout<<text[i]<<" ";
}
return 0;
}