I have a question on I/O buffering, can somebody help me out:
int main() {
int c;
printf("Hello World from PID=%d.",getpid());
sleep(10);
printf("Hello Again, World! from PID=%d.\n",getpid());
return 0;
}
the above program sleeps for 10 sec and then print out's the printf's.
Whereas, the one below print's out the statement before new line and sleeps for
10 seconds. I want to understand why is that ?
#include <stdio.h>
int main() {
int c;
printf("Hello World from PID=%d.\n",getpid());
sleep(10);
printf("Hello Again, World! from PID=%d.\n",getpid());
return 0;
}
Thanks