filebuf* open (const char* filename, ios_base::openmode mode);
filebuf* open (const char* filename, ios_base::openmode mode);filebuf* open (const string filename, ios_base::openmode mode);
| value | stands for | access |
|---|---|---|
| ios_base::in | input | File open for reading, supporting input operations. |
| ios_base::out | output | File open for writing, supporting output operations. |
| ios_base::binary | binary | Operations are performed in binary mode rather than text. |
| ios_base::ate | at end | The put pointer (pptr ) starts at the end of the controlled output sequence. |
| ios_base::app | append | All output operations happen at the end of the file, appending to its existing contents. |
| ios_base::trunc | truncate | Any contents that existed in the file before it is open are discarded. |
|).this if successful.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// filebuf::open()
#include <iostream>
#include <fstream>
int main () {
std::ifstream is;
std::filebuf * fb = is.rdbuf();
fb->open ("test.txt",std::ios::out|std::ios::app);
// >> appending operations here <<
fb->close();
return 0;
}