Chapter 14 describes advanced concepts surrounding C++ files.
Section 14.1 - Files
What is the difference between the fstream, ifstream, and ostream classes?
List two different ways to open a file.
How do you open a file for both input and output?
What is a possible disadvantage of using the eof() member function to detect end-of-file, rather than the fail() member function?
Section 14.2 - Output formatting
An I/O manipulator can be used to alter the formatting of output data sent to an stream. Briefly define each of these:
The I/O manipulators are also available as member functions to a stream. Show how each of the manipulators above can be invoked using a function call.
The setw() modifier has a fundamental difference in it behavior than the other modifiers. What is it?
What is a strstream?
Section 14.3 - Passing file stream objects to functions
Is it better to pass stream objects "pass-by-value" or "pass-by-reference"? Why?
Section 14.4 - More detailed error testing
The fail() member function can detect the failure of a stream. How can the stream be returned to normal function after an error.
Section 14.5 - Member functions
Describe each fstream member function:
Use seekg() to accomplish the following on an fstream:
Section 14.6 - Working with multiple files
If you need 12 files opened in your program at one time, how can this be accomplished in C++?
Section 14.7 - Binary files
Why are binary files smaller than ASCII files? Why are they faster?
What does the ios::binary flag do? This is a trick question... if you can tell me, I'd like to know.
Here are the binary I/O member functions:
Show an example of reading 20 bytes from an fstream. Show an example of writing 100 bytes.
Section 14.8 - Structure Blasters
Note: The archaic term for this section is "Structure Blasters" because structures in C were "blasted" to/from files in a single function call.
Why must structures contain only fixed-length fields to be read/written using C++ binary read/write functions? What is an example of a field that is not fixed-length and cannot be "blasted".
Can structures that contain pointers to other structures be "blasted"?
Show an example of reading a structure called Example from an fstream. Show an example writing a structure called DormRoom to an fstream.
Section 14.9 - Random-access files
What is the difference between seekg and seekp?
Why is this section called "random-access files"? What new capability does it describe?
What do these guys do:
Section 14.10 - Opening a file for both input and output
Done.
If you're still a little foggy, the "Review Questions and Exercises" fill-in-the-blanks section is pretty nice.