</pre><pre name="code" class="cpp">#include<iostream>
#include<string>
using namespace std;
int main()
{
freopen("D:\\output.txt","w",stdout);
string str;
while(cin >> str)
{
cout <<str<<endl;
}
fclose(stdout);
return 0;
}
把结果输出到D盘下的output.txt文件中
#include<iostream>
#include<string>
using namespace std;
int main()
{
freopen("/home/output.txt","w",stdout);
string str;
while(cin >> str)
{
cout <<str<<endl;
}
fclose(stdout);
return 0;
}
在linux中输出到文件