printf() put your line in the buffer, and as soon as you go down the line, it will write it to the screen. why when do you
printf(" Todays date is ..........:"); system("/bin/date");
You can print the date first.
The stdout stream is buffered, so it will only show what is in the buffer after it reaches a new line (or when it was said). You have several print options at once:
Type stderr instead of fprintf :
fprintf(stderr, "I will be printed immediately");
Reset stdout whenever you need to use fflush :
printf("Buffered, will be flushed"); fflush(stdout);
or you can disable buffering on stdout with setbuf :
setbuf(stdout, NULL);
source share