O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

File Access with iostream

One of the most useful streams that is derived from the iostream class is used to handle files. Although it exists in input file, output file, and input/output file variations, this section covers only the two-way fstream class.

The code in the following discussion always shows the class name and member function as follows:

<class>::<function>

Recall that, in order to actually use the class, it is necessary to take the appropriate steps to construct an object of that class before accessing the member function.

For example:

<class> <object>;
<object>.<function>;

To open a file, you need to specify the name and the mode. The general definition is as follows:

fstream::open ( char * pFilename, <mode> ) ;

In this code, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required