【发布时间】:2015-09-03 02:43:31
【问题描述】:
我们如何在屏幕上打印数据并同时将其保存为文本?
ofstream helloworld;
string hello ="welcome";
helloworld.open("helloworld.txt");
**helloworld << hello <<endl;
cout << hello << endl;**
有没有办法同时打印和写入文件??
cout&&helloworld <<hello<< endl;
【问题讨论】:
-
为什么不创建一个接受两个输入的方法:1)一个文件输出句柄,以及 2)要输出的行/字符串?在该例程中,
cout和file.write可以在该例程中执行,而不是在其他地方重复。 -
查看日志框架
标签: c++ visual-c++