How to do flushing in c++?

How to flush and why to use it ?

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.