How to do flushing in c++?

c-plus-plus

#1

How to flush and why to use it ?


#2

In C++ you may use fflush(stdout) or cout << flush (it depends on what do you use for output data — scanf/printf or cout).

Also, using cout<<endl in C++ performs flush operation automatically.