Here is some C code :
int i;
printf("This text is printed\nThis text is not until the for loop end.");
for (i = 5; i > 0; i--)
{
printf("%d", i);
sleep(1);
}
Why is the rest of the text after the '\n'
not printed before the for
loop start? Even the printf inside the for loop is only printed after the loop end.
If I put a '\n'
at the end of the text, it prints, but I do not want a new line.
This only happens on Linux and not on Windows (just changed sleep(1) to Sleep(1000) and added windows.h).