gpt4 book ai didi

c++ - endl 并刷新缓冲区

转载 作者:IT老高 更新时间:2023-10-28 12:44:53 27 4
gpt4 key购买 nike

C++入门一书的第(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++ - endl 并刷新缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4751972/

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