What is meant by 'flushing the stream'?

后端 未结 2 1089
我寻月下人不归
我寻月下人不归 2021-02-01 23:17

I\'ve read that \'\\n\' is preferred over \'endl\' for new line in c++ because \'endl\' inserts new line and flushes the stream. Please tell me what is flushing the stream ?

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-02 00:16

    Flushing a stream ensures that all data that has been written to that stream is output, including clearing any that may have been buffered.

    Some streams are buffered to aid performance, e.g. a stream writing to disk may buffer until the content reaches a block size.

提交回复
热议问题