| member | constant | opening mode |
|---|---|---|
| app | (append) | Set the stream's position indicator to the end of the stream before each output operation. |
| ate | (at end) | Set the stream's position indicator to the end of the stream on opening. |
| binary | (binary) | Consider stream as binary rather than text. |
| in | (input) | Allow input operations on the stream. |
| out | (output) | Allow output operations on the stream. |
| trunc | (truncate) | Any current content is discarded, assuming a length of zero on opening. |
write
std::ofstream out("data.txt", std::ios::app);
out << "This line will be appended to the end of the file";
out.close();
read
std::ofstream out2("data.txt", std::ios::in | std::ios::ate );
out2 << "This line will be ate to the end of the file";
out2.close();