you can create a "temporary file" say "tmp.txt" open it in "append mod" write you current text in it and after that copy your original file to it say: "file.txt".
Now,close "file.txt" and open it in "writing mod" and copy "tmp.txt" to "file.txt".
Or, if you don't want to #include <windows.h>, you can use the standard C functions unlink() or remove(). They are exactly the same, and you call them in the same way as DeleteFile:
The way I have approached this problem in the past has been:
open temp file in append mode
write preprended data
open existing file in read mode
copy data from existing file to temp file
delete existing file
rename temp file to (previously) existing file name
This saves having to copy temp file to existing file.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.