iostream hierarchy filebuf:: open |
cplusplus.com |
Open a file.
Opens a file whose name is s, associating its content with the stream
buffer to perform operations allowed by parameter mode.
Parameters.
bit effect app (append) Seek to the end of the stream before each output operation. ate (at end) Seek to the end of the stream when opening. binary Consider stream as binary rather than text. in Allow input operations on a stream. out Allow output operations on a stream. trunc (truncate) Truncate file to zero when opening.
Return Value.
The function returns this if successful.
In case of error, function returns a null pointer.
Example.
// filebuf::open ()
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream is;
filebuf * fb;
fb = is.rdbuf();
fb->open ("test.txt",ios::in);
// >> file buffer operations here <<
fb->close();
return 0;
}
Basic template member declaration ( basic_filebuf<charT,traits> ):
basic_filebuf* open ( const char* s, ios_base::openmode mode ); |
See also.
close,
is_open
filebuf class