刷新标准输出 [英] Flushing the standard output

查看:111
本文介绍了刷新标准输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刷新标准输出是什么意思?

What is the meaning of "flushing the standard output"?

推荐答案

标准输出被缓冲,刷新意味着清空缓冲区。您的输出语句保存在内存中,直到缓冲区填满或刷新它,然后将它们一次性转储到控制台。这样做的原因是节省时间。


例如,如果你有一个程序,那就是
cout<< "东西英寸;

某事在有人冲洗缓冲区或填满之前,它不会进入屏幕,这可能是相当长的一段时间但通常没有人关心。


使用''flush'冲洗缓冲区'或''endl''在你的cout声明中。


我假设是c ++,但如果你指的是c land同样的概念也适用,除了你printf换行符\ n刷新缓冲区。


通常,如果您希望输出立即显示(无缓冲),请使用

cerr<<来写入stderr。 "东西英寸;



fprintf(stderr,what what);
Standard output is buffered, flushing it means to empty the buffer. Your output statements are held in memory until the buffer fills or you flush it, then they are dumped to the console all at once. The reason for this is time savings.

For instance, if you have a program that does
cout << "something";
the "something" will not make it to the screen until somebody flushes the buffer or it fills up, which may be quite some time but usually nobody cares.

The buffer is flushed by using ''flush'' or ''endl'' in your cout statement.

I''m assuming c++, but if you''re referring to c land the same concept holds true except that you printf a newline "\n" to flush the buffer.

Usually, if you want your output to appear immediately (unbuffered) you write to stderr using
cerr << "something";
or
fprintf(stderr,"whatever");


非常感谢...我理解这一个。 ..我用fflush()写了一个程序,我写的但测试系统不接受。这是任务 http://day0.ioi2009.org/data/Hill.pdf 这是我的解决方案:

Thanks a lot... Just I understood this one... I asked to write a program using fflush(), I wrote but testing system does not accept. this is taskhttp://day0.ioi2009.org/data/Hill.pdf and here is my solution:

展开 | 选择 | Wrap | 行号


我看了你的作业页面,它给出了预期的输入和输出样本。


我认为你只需要运行你的程序并密切关注你的代码并遵循执行的路径,你应该能够找出问题。


您是否尝试使用给定的示例输入运行程序?

它做得不正确?
I looked at your assignment page and it gives an expected input and output sample.

I think you just need to run your program and look closely at your code and follow the path of execution and you should be able to figure out the problem.

Have you tried running your program using the given sample input?
What did it not do correctly?


这篇关于刷新标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆