结束并冲洗缓冲区 [英] endl and flushing the buffer

查看:80
本文介绍了结束并冲洗缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++入门书的第(1)章中,它提到了以下内容:

In the C++ primer book, in chapter (1), it mentions the following:


endl是一个特殊的值,称为操纵器,它在写入
输出流时具有将换行符写入输出和
冲刷与该设备关联的缓冲区的作用。 通过刷新缓冲区,我们确保用户将立即看到输出写入
流。

这里的刷新缓冲区是什么意思?

What is meant by "flushing the buffer" here?

推荐答案

通常在将输出写入目标之前对其进行缓冲设备。这样,当写入慢速访问设备(如文件)时,不必在每个字符后都访问设备。

Output is generally buffered before it's written to the intended device. That way, when writing to slow to access devices(like files), it doesn't have to access the device after every single character.

刷新意味着清空缓冲区,然后实际将其写入设备。

Flushing means emptying the buffer and actually writing it to the device.

这篇关于结束并冲洗缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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