Chapter 15. Stream Input/Output
Consciousness ... does not appear to itself chopped up in bits ... A "river" or a "stream" are the metaphors by which it is most naturally described.
All the news that's fit to print.
Adolph S. Ochs
Remove not the landmark on the boundary of the fields.
In this chapter you will learn:
To use C++ object-oriented stream input/output.
To format input and output.
The stream-I/O class hierarchy.
To use stream manipulators.
To control justification and padding.
To determine the success or failure of input/output operations.
To tie output streams to input streams.
15.2.1 Classic Streams vs. Standard Streams
15.2.2 iostream Library Header Files
15.2.3 Stream Input/Output Classes and Objects
15.3 Stream Output
15.3.1 Output of char * Variables
15.3.2 Character Output using Member Function put
15.4 Stream Input
15.4.1 get and getline Member Functions
15.4.2 istream Member Functions peek, putback and ignore
15.4.3 Type-Safe I/O
15.5 Unformatted I/O using read, write and gcount
15.6 Introduction to Stream Manipulators
15.6.1 Integral Stream Base: dec, oct, hex and setbase
15.6.2 Floating-Point Precision (precision, setprecision)
15.6.3 Field Width (width, setw)
15.6.4 User-Defined Output Stream Manipulators
15.7 Stream Format States and Stream Manipulators
15.7.1 Trailing Zeros and Decimal Points (showpoint)
15.7.2 Justification (left, right and internal)
15.7.3 Padding (fill, setfill)
15.7.4 Integral Stream Base (dec, oct, hex, showbase)
15.7.5 Floating-Point Numbers; Scientific and Fixed Notation (scientific, fixed)
15.7.6 Uppercase/Lowercase Control (uppercase)
15.7.7 Specifying Boolean Format (boolalpha)
15.7.8 Setting and Resetting the Format State via Member-Function flags
15.8 Stream Error States
15.9 Tying an Output Stream to an Input Stream
Answers to Self-Review Exercises