ios_base::openmode type — Open mode bits


typedef  . . .  openmode
typedef  . . .  open_mode
static const openmode app
static const openmode ate
static const openmode binary
static const openmode in
static const openmode out
static const openmode trunc
image with no caption

The ios_base::openmode type is an integer, enum, or bitset type (the exact type is implementation-defined) that defines the mode for opening a file. The open_mode type is an integral type that represents the same information. Some functions that take an openmode parameter have an overloaded version that accepts an open_mode parameter and has the same functionality as its openmode counterpart. The open_mode type and related functions are deprecated, so you should use the openmode versions.

Table 13-16 lists the openmode literals and their meanings. (Refer to the <fstream> section of this chapter for the most common use of ios_base::openmode and the permitted combinations of openmode literals.) The openmode type is also used for the basic_streambuf::pubseekoff and pubseekpos functions, and for related functions.

Table 13-16. openmode literals




Seeks to end-of-file before each write


Seeks to end-of-file immediately after opening


Reads and writes in binary mode (default is text)


Opens for input (reading)


Opens for output (writing)


Truncates file to zero length

See Also

<bitset>, basic_filebuf ...

Get C++ In a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.