gpt4 book ai didi

c++ - 结束并刷新缓冲区

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:50:20 33 4
gpt4 key购买 nike

C++ primer 一书中,第 (1) 章提到了以下内容:

endl is a special value, called a manipulator, that when written to an output stream has the effect of writing a newline to the output and flushing the buffer associated with that device. By flushing the buffer, we ensure that the user will see the output written to the stream immediately.

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

最佳答案

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

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

关于c++ - 结束并刷新缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30194877/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com