Writting in a saved File.

Hi, I have a text file with some saved lines.
I want to add a new line to the file, after each compilation of my code.
I need to keep the previous data.
But

For example:
File A contains:
AAAABBBB
CCCCDDDD
EEEEFFFF
----------

For the first time, when I run the code, a new line(for example xxxxxxxx) is produced and I want to add it to the previous lines. Also for the next runs, similar will happen.

first run:
AAAABBBB
CCCCDDDD
EEEEFFFF
xxxxxxxx

second run:
AAAABBBB
CCCCDDDD
EEEEFFFF
xxxxxxxx
YYYYYYYY

and ...

I tried to implement it by ostream and istream, but each time it just removes the previous lines, and Just shows new line.
How can I implement it?
you need to open it with flags -- specifically 'ate' (yes, really). or maybe 'app'. See which one you think you want:
https://www.cplusplus.com/reference/fstream/fstream/open/
Last edited on
Probably "app"– append. I'm not sure what "ate" is.
AT - E nd ... it positions the file pointer to the end, but I did not look to see what the diff in the two was. What little text file stuff I do is just open / grab / close or open / dump / close.
Last edited on
Topic archived. No new replies allowed.