I have a C program with 9 calls to printf and I need it to run on a remote server for several days. So I decided to redirect the stdout to a file to check the progresses:
FILE *foutput=freopen("output.txt","w",stdout);
After some debugging I found this and used
fflush(foutput)
and from what I can see in the link, all the buffering are right to me (I have a newline command at the end of each print): right in the sense that I expect the print to be effectively executed and to find them on output.txt, but this is not happening.
What may be the problem?
I want you to note that following works:
foutput=freopen("output.txt", "w", stdout);
printf("first print\n");
fflush(foutput);
fclose(foutput);
but I'd like to avoid the call to freopen
each time.