Hello
I want the ofstream to write at the end of a file without erasing its content inside.
how can i do it? (i'm talking about txt files,and C++)
Thanks.
views:
234answers:
4
+7
A:
You can pass the flag ios::app
when opening the file:
ofstream ofs("filename", ios::app);
Konrad Rudolph
2008-10-01 13:52:46
+1
A:
You want to append to the file. Use ios::app as the file mode when creating the ofstream.
Appending will automatically seek to the end of the file.
Ed Haber
2008-10-01 13:55:25
A:
you can also manually move the pointer once the file is open using seekp()
Nona Urbiz
2009-09-28 18:51:56