Unbuffered output with cout

You can set the std::ios_base::unitbuf flag to flush output after each output operation either by calling std::ios_base::setf:

std::cout.setf(std::ios::unitbuf);

or using the std::unitbuf manipulator:

std::cout << std::unitbuf;

Leave a Comment