#include<iostream>
#include<fstream>
#include<string>
using namespace std;
ifstream fin ("d:/test1.txt");
ofstream fout("d:/test2.txt");
int main()
{
string str,res;
while (fin >> str)
res += str+'\n';
fout << res << endl;
return 0;
}
Run
test1:
abc defg hijk pqr
test2:
abc
defg
hijk
pqr