c++ - endl 并刷新缓冲区

标签 c++ buffer flush

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/

相关文章:

c++ - 奇怪的指针行为 C++/继承

c++ - 没有图形 API 的可移植实时渲染器窗口

Android:OutputStreamWriter 刷新后未发送数据(套接字)

caching - clflush 指令是否仅从 1 级缓存刷新 block ?

c++ - 异步 FTP 库

C++:我如何从这段代码制作这个形状?

c - 如何发送大小大于 64 KB 的 UDP 数据包

c - 我一定是在某处使用 recv( ) 从 TCP 套接字接收数据时遇到了缓冲区限制

c++ - 在循环中使用 strtof 解析字符缓冲区中的数字

hibernate - 选择给定数据时防止刷新 EntityManager