在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/