#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <fstream>
#include <cctype>
using namespace std;
int main(void)
{
vector<string> coll;
vector<string>::iterator pos;
cout<<"Pls input string:"<<endl;
fstream fout("/home/C++/input_file",
fstream::trunc|fstream::in|fstream::out);
if (!fout){
cout << "File open error!\n";
return 0;
}
copy(istream_iterator<string>(cin),
istream_iterator <string>(),
back_inserter(coll));
for(pos=coll.begin(); pos!=coll.end(); ++pos)
{
//cout<<*pos<<" ";
transform(pos->begin(), pos->end(),pos->begin(), ::toupper);
}
copy(coll.begin(), coll.end(), ostream_iterator<string>(fout," "));
//也可将输入流直接重定向到文件
//copy(istream_iterator<string>(cin), ostream_iterator<string>(), ostream_iterator<string>(fout,"")cout<<endl;
fout.close();
}