fstream::open
void open ( const char * filename, openmode mode = in | out ); | fstream |
cplusplus.com |
Open a file.
Opens a file. The stream's file buffer is associated with the specified file to
perform the i/o operations.
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.
none
Example.
// fstream::open
#include <fstream>
using namespace std;
int main () {
fstream filestr;
filestr.open ("test.txt", fstream::in | fstream::out | fstream::app);
// >> i/o operations here <<
filestr.close();
return 0;
}
This example opens a file and appends a sentence to its content.
Basic template member declaration ( basic_fstream<charT,traits> ):
void open ( const char * filename, openmode mode = in | out ); |
See also.
close
fstream class