If the object already has a file associated (open), this function fails.
Parameters
- s
- C-string containg the name of the file to be opened.
- mode
- Flags describing the requested i/o mode for the file. This is an object of type ios_base::openmode. It consists of a combination of the following member constants:
flag value 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.
Return Value
The function returns this if successful.In case of failure, close is called and a null pointer is returned.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Basic template member declaration
( basic_filebuf<charT,traits> ) |
See also
| filebuf::is_open | Check if a file is open (public member function) |
| filebuf::close | Close file (public member function) |
