The problem with redirecting the output to a file in debug mode is that I can not view the content of file (size is zero) until the program finish. With this usages:
FILE *f;
f = fopen("log.txt", "w");
fprintf(f, "cycle =%d\n", c);
while I am debugging, I want to view the track “cycle =” in the file right after stepping out “fprintf” statement.
Is there any way to do that?
You can try to put
fflush(f);afterfprintf()function call, which will make the data be written immediately.