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:
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.
<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, ...