If I have a loop and inside it a process then output to a file , after the loop end close file . The program have been running for a while , but since close file after the loop , when I open the output file no output was there . Is there a way I can see the output or I can stop the program and let it write what it has processed to the output file ?
for ( int i =0 ; i < 1000 ; i +++)
{
// do some calculations
fileoutput.write(...);
}
fileoutput.close();
If the program is producing some output, but is buffering it, there’s no way to externally prod it into flushing the buffer.
Your best bet is to modify the loop to call
fileoutput.flush(), and re-run:This way you’ll be able to see the data appear in the file as it gets written.