io:flush

C++ Reference

flush

Syntax:

    #include <fstream>
    ostream& flush();

The flush() function causes the buffer for the current output stream to be actually written out to the attached device. This function is useful for printing out debugging information, because sometimes programs abort before they have a chance to write their output buffers to the screen. Judicious use of flush() can ensure that all of your debugging statements actually get printed.

You should use cerr for debugging, which does not buffer output by default.

Related Topics: put, write