C++ Manipulator flushC++ manipulator flush is used to synchronize the associated stream buffer with its controlled output sequence. For the stream buffer, objects that implement intermediate buffers, flush function is used to request all characters written to the controlled sequence. SyntaxParameteros: Output stream object affected. Return valueIt returns argument os. Data RacesModifies the stream object os. If we try to concurrent access to the same stream object then it may cause data races, except for the standard stream objects cerr, cout, wcout, clog, wcerr and wclog when these are synchronized with stdio. ExceptionsObject os is in a valid state, if any exception is thrown. Example 1Let's see the simple example to demonstrate the use of flush: Output: Output- This program requests test.txt to be flushed 100 times. Example 2Let's see another simple example: Output: ..(435 ms)....(899 ms)....(1332 ms)....(1755 ms)....(2192 ms).. Example 3Let's see another simple example: Output: The Value of a is :10 The Value of b is :20 The Value of c is :40
Next TopicC++ Manipulator
|