Several Data Types. McGraw-Hill The Complete Reference Fourth Edition
Реклама
Реклама
C h a p t e r 3 2 : T h e S t a n d a r d C + + I / O C l a s s e s
793
Several Data Types
In addition to the fmtflags type just described, the Standard C++ I/O system defines several other types.
The streamsize and streamoff Types
An object of type streamsize is capable of holding the largest number of bytes that will be transferred in any one I/O operation. It is typically some form of integer. An object of type streamoff is capable of holding a value that indicates an offset position within a stream. It is typically some form of integer. These types are defined in the header <ios>, which is automatically included by the I/O system.
The streampos and wstreampos Types
An object of type streampos is capable of holding a value that represents a position within a char stream. The wstreampos type is capable of holding a value that represents a position with a wchar_t stream. These are defined in <iosfwd>, which is automatically included by the I/O system.
The pos_type and off_type Types
The types pos_type and off_type create objects (typically integers) that are capable of holding a value that represents the position and an offset, respectively, within a stream.
These types are defined by ios (and other classes) and are essentially the same as
streamoff
and streampos (or their wide-character equivalents).
The openmode Type
The type openmode is defined by ios_base and describes how a file will be opened.
It will be one or more of these values.
app ate binary in out trunc
Append to end of file.
Seek to end of file on creation.
Open file for binary operations.
Open file for input.
Open file for output.
Erase previously existing file.
You can combine two or more of these values by ORing them together.
Изтегляне
Реклама