Possible Duplicate:
Why does printf not flush after the call unless a newline is in the format string? (in C)
I faced this problem while doing a networking project. I was able to narrow down the issue and reproduce it like this:
If you run this code, it wont display the text on the screen. Although it displays the text if you put \n at the end of the text or use fflush() after the printf statement.
int main(){
printf("started") ;
while(1){
}
}
Can anyone please explain this behavior?
The output just doesn't get flushed to the screen without the \n.
Add fflush(stdout); after the printf and you should see the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With