Javatpoint Logo
Javatpoint Logo

C++ Manipulator flush

C++ 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.

Syntax

Parameter

os: Output stream object affected.

Return value

It returns argument os.

Data Races

Modifies 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.

Exceptions

Object os is in a valid state, if any exception is thrown.

Example 1

Let's see the simple example to demonstrate the use of flush:

Output:

Output- This program requests test.txt to be flushed 100 times.

Example 2

Let's see another simple example:

Output:

..(435 ms)....(899 ms)....(1332 ms)....(1755 ms)....(2192 ms)..

Example 3

Let'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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA