In cpp reference, it claims fflush is:
Causes the output file stream to be synchronized with the actual contents of the file.
Indeed, I don't understand what it means. I just wonder, in that code, if I take out fflush, is there any difference?
I tested it, it seems there is a little bit difference, but I can't find the pattern. Could any one explain it in details for me? Thanks in advance.
#include<stdio.h>
int i;
int main()
{
fork();
for(i=0;i<1000;i++)
{
printf("%d\n",i);
fflush(stdout);// without fflush, is there any difference?
}
}