运行结果不同于预期
#include<iostream>#include<string>
#include<vector>
using namespace std;
int main()
{vector<const char*> cvec;
string s1;
while(cin>>s1&&s1!="end")
cvec.push_back(s1.c_str());
for(vector<const char*>::iterator it=cvec.begin();it!=cvec.end();++it)
cout<<*it<<endl;
return 0;
}
运行结果为:
ab cd end
end
end
Press any key to continue!