Next: Connecting Streams to External
Up: Streams and External Files
Previous: Streams and External Files
In C++ data is written to and from streams. A stream is :
The streams cin
and cout
which are connected to the
keyboard and the screen respectively have already been considered.
When using these streams the file iostream.h
must be included
in the program.
C++ allows other streams to be set up. These streams must be declared
just as identifiers are declared. Thus streams that are to be used
for input are declared as having the type ifstream
and those
that are used for output are declared as having the type
ofstream
. Once a stream has been declared it must be
connected to an external file.
If streams are going to be used the file fstream.h
must be
included in the program.