when opening a file does ofstream deletes its content by default? If so, how do I cancel that? I don't want to use app, because I need to edit the file between the existing characters.

from this I understood I should use output.open("test.txt" , iostream::ate);
it still deletes the previous content though
but then I can only add output at the end of the file (that's what I understand at least).. I don't want that
Sorry, I misread the question.
This might be better:
fstream fout("test.txt", ios_base::in | ios_base::out | ios_base::ate);
The first time this is run, if the file does not already exist, it will give an error, so you may need alternative logic for that case.
yeah this is working. Thank you!
Topic archived. No new replies allowed.