Manual cout reset only

As far as I know, streaming std::endl

in std::cout

will be hidden. I understand that this behavior makes sense for most applications.

My problem is that I have some output that uses multiple std::endl

and therefore clears the output. This is very bad for the performance of my program and also causes a lot of graphical glitches as I jump a lot.

So my question is, can I say std::cout

wait from next reset until I explicitly call std::cout.flush()

or thread std::flush

in std::cout

.
If possible, I would also like to know how I can then change it, because it doesn't always make sense to me.

+3


source to share


1 answer


Use std::cout << '\n'

instead std::endl

. This avoids a flush after each line. std::endl

will always be short-lived, since that is his goal. There is no way to disable this behavior. However, there is no need to use it std::endl

at all.



If you want to increase the buffer size for standard output, you can try increasing the buffer for cout .

+6


source







All Articles