您的位置:首页 > 运维架构 > Linux

在win7和linux中把输出的结果放到文件

2014-12-09 15:52 232 查看
</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中输出到文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: