I am trying to understand the behavior of std::flush
, but I could not notice any difference in output, with and without using flush
, (ie) every second one number is printed in both cases.
I am using Visual Studio 2015. Does my compiler automatically flush?
How can I notice a difference?
Here's the example I took from Quora:
int main()
{
for (int i = 1; i < 11; ++i)
{
Sleep(1000);
cout<<i<<" "<<flush; // same output when i run without flush
}
return 0;
}