| iostream hierarchy ostream:: flush | 
| cplusplus.com | 
 Flush buffer.
 
If the stream is a buffered stream, the buffer is synchronized with the
physical media associated with it.
 
Buffered streams are usually used when a physical device that
is significantly slower than memory access (like files)
is associated with a stream. This allows to perform the input and output
operations on a memory buffer instead of directly on the device, thus accelerating
considerably the operations. A call to this member function forces the stream's buffer
to syncronize its data with the content of the physical device associated with it.
Parameters.
 Return Value.
 
*this
 Example.
// Flushing files
#include <fstream>
using namespace std;
int main () {
  ofstream outfile ("test.txt");
  for (int n=0; n<100; n++)
  {
    outfile << n;
    outfile.flush();
  }
  outfile.close();
  return 0;
}
 
When this example is executed the content of the file test.txt is updated 100 times.
Basic template member declaration (basic_ostream<charT,traits>):
| basic_ostream& flush ( ); | 
 See also.
 
flush manipulator,
endl manipulator
 
ostream class