I think this should be quite simple, but my googling didn\'t help so far... I need to write to an existing file in C++, but not necessarily at the end of the file.
I
You cannot insert in the middle of the file. You have to copy the old file to a new file and insert whatever you want in the middle during copying to the new file.
Otherwise, if you intend to overwrite data/lines in the existing file, that is possible by using std::ostream::seekp()
to identify the position within the file.