求:能够体现有和没有 flush ,对结果不同的代码

unhappyless_02 2006-12-11 10:30:27
1.输出缓冲区的刷新

cout<<"h1!"<<flush; //求:能够体现有和没有 flush ,对结果不同的代码
...全文
198 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
unhappyless_02 2006-12-15
  • 打赏
  • 举报
回复
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream file("redirect.txt");

// redirect ouput into the file
file <<"line-1\n";

file << "line-2\n";
file.flush();

file << "line-3\n";
}

这 有和没有 flush 不都一样?
OOPhaisky 2006-12-13
  • 打赏
  • 举报
回复
呵呵,楼主还是满认真的吗,一定要看到效果,精神可嘉^_^
missilery 2006-12-13
  • 打赏
  • 举报
回复
#include <fstream>
taodm 2006-12-13
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/TopicView1.asp?id=5227635
这个正是你要的代码嘛。
搞不清楚你们这一堆unhappyless_XX是马甲还是同学。
unhappyless_02 2006-12-13
  • 打赏
  • 举报
回复
#include<iostream>
#include<sstream>
using namespace std;
int main()
{
ofstream file("redirect.txt");

// redirect ouput into the file
file <<"line-1\n";

file << "line-2\n";
file.flush();

file << "line-3\n";
}

有一些错误
taodm 2006-12-12
  • 打赏
  • 举报
回复
算了吧,现在已经很难体现出这一点了。
missilery 2006-12-12
  • 打赏
  • 举报
回复
ofstream file("redirect.txt");

// redirect ouput into the file
file << "line-1\n";

file << "line-2\n";
file.flush();

file << "line-3\n";
unhappyless_02 2006-12-12
  • 打赏
  • 举报
回复
怎么说很难体现?硬件配置?
stonejiang 2006-12-11
  • 打赏
  • 举报
回复
不太明白楼主的意思,flush 的功能就是让缓冲区中的数据直接读出 而没有延迟,程序输出的结果应该跟flush没有什么联系
lei001 2006-12-11
  • 打赏
  • 举报
回复
msdn中应该有例子吧

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧