Standard C++ Library Reference ISO/IEC (VERSION3)

IostreamsConventions
The iostreams headers support conversions between text and encoded forms, and input and
output to external files: <fstream>, <iomanip>, <ios>, <iosfwd>, <iostream>,
<istream>, <ostream>, <sstream>, <streambuf>, and <strstream>.
The simplest use of iostreams requires only that you include the header <iostream>. You
can then extract values from cin, to read the standard input. The rules for doing so are outlined
in the description of the class basic_istream. You can also insert values to cout, to write
the standard output. The rules for doing so are outlined in the description of the class
basic_ostream. Format control common to both extractors and insertors is managed by the
class basic_ios. Manipulating this format information in the guise of extracting and
inserting objects is the province of several manipulators.
You can perform the same iostreams operations on files that you open by name, using the
classes declared in <fstream>. To convert between iostreams and objects of class
basic_string, use the classes declared in <sstream>. And to do the same with C strings,
use the classes declared in <strstream>.
The remaining headers provide support services, typically of direct interest to only the most
advanced users of the iostreams classes.
C++ Program Startup and Termination
A C++ program performs the same operations as does a C program program startup and at
program termination, plus a few more outlined here.
Before the target environment calls the function main, and after it stores any constant initial
values you specify in all objects that have static duration, the program executes any remaining
constructors for such static objects. The order of execution is not specified between translation
units, but you can nevertheless assume that some iostreams objects are properly initialized for
use by these static constructors. These control text streams:
cin -- for standard input
cout -- for standard output
cerr -- for unbuffered standard error output
clog -- for buffered standard error output
You can also use these objects within the destructors called for static objects, during program
termination.
As with C, returning from main or calling exit calls all functions registered with atexit in
reverse order of registry. An exception thrown from such a registered function calls