flush [C++ Reference]
Keywords: io,flush
Date: 2009-03-09T12:16:07-0700

## flush

Syntax:

        ostream& 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