As much as I know, we do not get output to the screen from cout, until:
1.Buffer is full
2.Buffer is flushed
3.Program is terminated
So i have written following Code:
for(;;)
{
cout << "a";
_sleep(1000);
}
Compiler:clang++
Also tested on g++
OS: Windows 11
Every second I get an output? Why and how?
std::this_thread::sleep_foror windowsSleepboth result in the behaviour you expect. Might be OS or compiler specific, you should add this information.