Standard C++ Library Reference ISO/IEC (VERSION3)
fopen(filename, strmode). Here strmode is determined from mode & ~(ate &
| binary):
ios_base::in becomes "r" (open existing file for reading).●
ios_base::out or ios_base::out | ios_base::trunc becomes "w"
(truncate existing file or create for writing).
●
ios_base::out | app becomes "a" (open existing file for appending all writes).●
ios_base::in | ios_base::out becomes "r+" (open existing file for reading
and writing).
●
ios_base::in | ios_base::out | ios_base::trunc becomes "w+"
(truncate existing file or create for reading and writing).
●
ios_base::in | ios_base::out | ios_base::app becomes "a+" (open
existing file for reading and for appending all writes).
●
If mode & ios_base::binary is nonzero, the function appends b to strmode to open a
binary stream instead of a text stream. It then stores the value returned by fopen in the file
pointer fp. If mode & ios_base::ate is nonzero and the file pointer is not a null pointer,
the function calls fseek(fp, 0, SEEK_END) to position the stream at end-of-file. If that
positioning operation fails, the function calls close(fp) and stores a null pointer in the file
pointer.
If the file pointer is not a null pointer, the function determines the file conversion facet:
use_facet< codecvt<Elem, char, traits_type:: state_type>
>(getloc()), for use by underflow and overflow.
If the file pointer is a null pointer, the function returns a null pointer. Otherwise, it returns
this.
basic_filebuf::overflow
virtual int_type overflow(int_type meta =
traits_type::eof());
If meta != traits_type::eof(), the protected virtual member function endeavors to
insert the element ch = traits_type::to_char_type(meta) into the output buffer.
It can do so in various ways:
If a write position is available, it can store the element into the write position and
increment the next pointer for the output buffer.
●
It can make a write position available by allocating new or additional storage for the
output buffer.
●
It can convert any pending output in the output buffer, followed by ch, by using the file
conversion facet fac to call fac.out as needed. Each element ch of type char thus
produced is written to the associated stream designated by the file pointer fp as if by
●