How can I use a stream to write text to the end of a file without deleting its contents inside?
When opening a file, you can pass the flag ios::app:
ios::app
ofstream ofs("filename", ios::app);
You want to add a file. Use ios :: app as the file mode when creating the stream.
Adding will automatically search for the end of the file.
ios:: app .
seekp() .
seekp()
, :
ofstream out("path_to_file",ios::app);
, .
, , ios::app, :
out.seekp(0,ios::end) This will place a pointer to 0 bytes from the end of the file. http://www.cplusplus.com/reference/ostream/ostream/seekp
out.seekp(0,ios::end)
Make sure you use the correct seekp (), as there are 2 seekp () overloads. In this situation, two parameters are preferred.
Source: https://habr.com/ru/post/1697767/More articles:How to optimize PostgreSQL configuration? (Is there a tool available?) - optimization.NET Webservices Development Approach - .netISeries SQL procedure - check if it already exists - sqlThe join problem with the highest value in mysql table - sqlPartitioning a SQL 2005 Database for SharePoint - sql-server-2005Date and time formats for different countries - localeUnfamiliar character in SQL statement - sqlWhat is the consensus on Voice Family? - htmlWhy can't I use the Template Toolkit? - perlDotNetNuke "keepalive" - asp.netAll Articles