sleep() call
Hello,
I've run the following user application in the linux environment:
int main()
{
FILE * fp = fopen ("/log_file" , "w");
int n=0;
while(n++ < 20)
{
fprintf(fp, "%s", "OK");
sleep(1);
}
fclose(fp);
return 0;
}
The problem is that the file /log_file is created, but is empty.
If I remove the sleep() call, the file /log_file gets the "OK" strings.
How the sleep() call may interfere with the fprintf() call?
Any idea to solve this?
Thank you very much.
|