std::cout won’t print

Make sure you flush the stream. This is required because the output streams are buffered and you have no guarantee over when the buffer will be flushed unless you manually flush it yourself.

std::cout << "Hello" << std::endl;

std::endl will output a newline and flush the stream. Alternatively, std::flush will just do the flush. Flushing can also be done using the stream’s member function:

std::cout.flush();

Leave a Comment