also use mode std::ios::ate (AT End)
The default mode for ofstream opening is std::ios::trunc, (TRUNCate), which deletes any previous content of the file. ios::ate preserves the file, allows you to move the file pointer anywhere within the current content.
Reputation Points: 1268
Solved Threads: 228
Posting Virtuoso
Offline 1,895 posts
since Aug 2007