The function only has meaning for buffered streams, in which case it effectively calls the pubsync member of the streambuf object (rdbuf()->pubsync()) associated to the stream.
A manipulator exists with the same name and behavior (see flush manipulator).
Return ValueThe function returns *this.
If an error happens while flushing a buffered stream, the badbit flag is set (which can be checked with member bad). Also, depending on the values set through member exceptions, this may cause an exception of type ios_base::failure to be thrown.
When this example is executed the content of the file test.txt is updated 100 times.
Basic template member declaration( basic_ostream<charT,traits> )
|flush||Flush stream buffer (manipulator function)|
|endl||Insert newline and flush (manipulator function)|
|istream::sync||Synchronize input buffer with source of characters (public member function)|