Cout won't print text without endl inside while loop?

前端 未结 1 874
忘了有多久
忘了有多久 2021-01-18 23:08

I don\'t know if it\'s related to flush in ostream. Since, endl is end with flush right? I don\'t know what is flush and how it works.

I have a function that will pr

相关标签:
1条回答
  • 2021-01-18 23:36

    Flushing makes sure all output written to the stream so far is shown on the console.

    You can do std::cout << std::flush or std::cout.flush() after each output operation to make sure the output is shown on the console immediately.

    Right now it's just writing everything to the stream and only flushing the stream after the loop.

    0 讨论(0)
提交回复
热议问题