next up previous
Next: C++ and Unix I/O

\fbox{\Large \bf Physics 6720 - I/O Methods -
\normalsize October 30, 2002}


We have been using cin and cout to handle input from the keyboard and output to the screen. In these notes we discuss further useful capabilities of these standard C++ features: how to (1) redirect output selectively (2) detect an end of file condition and check for input data conversion errors, (3) control the format (number of digits, etc.) of output numeric values, and (4) read and write to a named file.

Now that we have introduced classes and discussed operator overloading, it is time to reveal the true identity of cin and cout. They are actually standard instances of the classes istream and ostream. The classes, their instances, and the overloading of the operators >> and << are defined in the <iostream.h> header. So in these notes we will be discussing some of the useful methods of these and related classes.





Carleton DeTar 2007-10-31