FStream.... myFile.flush() won't work

Started by
4 comments, last by johnnyBravo 20 years, 6 months ago
I assume the flush() command in FStream clears the file of any data. If not how do i do that. But if so: fstream fFile; fFile.open (filename, fstream::in | fstream::out | fstream::app); fFile.flush(); fFile.close(); but it seems to do nothing to the file Thanks
Advertisement
You assumed wrong. Read documentation instead of assuming.
i did, thats the only command i could find that mentioned anything like it.

http://www.cplusplus.com/ref/iostream/fstream/
Flush is not used to empty out a file. If you want the file to be emptied out, you need to do that with the flags.

There is a good article <a hef="http://www.gamedev.net/reference/articles/article1127.asp">here</a>.
Um, flush is used to clear I/O buffers and write to disk immediately.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
quote:Original post by Anonymous Poster
There is a good article <a hef="http://www.gamedev.net/reference/articles/article1127.asp">here</a>.

That article has old info (even though it was submitted in 2000, tsk tsk). It uses <fstream.h> and <iostream.h>. Those contain some things non-existent in the current <fstream> and <iostream> headers. Such as ios::noreplace and ios::nocreate.

This topic is closed to new replies.

Advertisement