c++ force std::cout flush (print to screen)

Solution 1:

Just insert std::flush:

std::cout << "Beginning computations..." << std::flush;

Also note that inserting std::endl will also flush after writing a newline.

Solution 2:

In addition to Joseph Mansfield answer, std::endl does the flush too (besides a new line).

Inserts a endline character into the output sequence os and flushes it as if by calling os.put(os.widen('\n')) followed by os.flush().