07-09-2009 02:55 AM
I read a line every time from a text file and write to another file in a loop. When i put flush function into loop, the disk will
make a little noise and i don't feel better. I don't know which is better to flush to file: after every write or after exit from loop.
Or don't need it at all. Anyone can help me about this?
Thanks.
07-09-2009 03:17 AM
You don't need to flush at all. The operating system will take care about this. When closing the file it will be flushed anyway.
You can use the flush function if you're continuously writing to a file from one application (keeping the file open) and reading from the file in another application (at the same time).
Hope this helps,
Daniel