Sometimes we noticed that
printf will only flush after there is a newline in the print string, this behavior is caused by
stdout stream buffer, which is line buffered by default. This behavior has been mentioned in ISO C99 standard:
There are few options to make it to print immediately once you called it.
fflush will flush
setbuf(stdout, NULL); will disable
It also have a secure version:
setvbuf (stdout, NULL, _IONBF, BUFSIZ);