Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |
The goal of the iostreams design is to allow you to easily
move and/or format characters. It certainly wouldn t be useful if you couldn t
do most of the formatting provided by C s printf( ) family of
functions. In this section, you ll learn all the output formatting functions
that are available for iostreams, so you can format your bytes the way you want
them.
The formatting functions in iostreams can be somewhat
confusing at first because there s often more than one way to control the
formatting: through both member functions and manipulators. To further confuse
things, a generic member function sets state flags to control formatting, such
as left or right justification, to use uppercase letters for hex notation, to
always use a decimal point for floating-point values, and so on. On the other
hand, separate member functions set and read values for the fill character, the
field width, and the precision.
In an attempt to clarify all this, we ll first examine the
internal formatting data of an iostream, along with the member functions that
can modify that data. (Everything can be controlled through the member
functions, if desired.) We ll cover the manipulators separately.
Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |