Asked • 05/24/19

The consequences and pros/cons of flushing the stream in c++?

I have recently read an article which stated that using `\\n` is preferable to using `std::endl` because `endl` also flushes the stream. But when I looked for a bit more information on the topic I found a site which stated: "If you are in a situation where you have to avoid buffering, you can use std::endl instead of ‘\\n’ " In which situation is it preferable not to write to the buffer? Because I only saw advantages of that technique. Isn't it also safer to write to the buffer? Because it is smaller than a hard drive it will get overwritten faster than data that is stored on the HD.

1 Expert Answer

By:

Patrick B. answered • 05/24/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.