Wyo C++ Ch. 11 Notes

Objective #1: Understand the uses for data files.

Objective #2: Understand the difference between sequential-access and random-access data files.

Objective #3: Open and close data files.

Objective #4: Write to data files.

Objective #5: Read from data files.

Objective #6: Add to the end of a data file.

ofstream appendFile;
appendFile.open("mydata.txt", ios::app);

rather than

appendFile.open("mydata.txt");

or

appendFile.open("mydata.txt", ios::out);

Objective #7: Detect the end of a file.

do
{
    infile >> x;

    if ( !infile.eof( ) )
    {
            cout << x << endl;
    }

} while ( !infile.eof( ) );

Objective #8: Use multiple data files at the same time and insert data into the middle of a sequential access file.

Objective #9: Prompt the user for file names.

Objective #9: Pass file stream objects as parameters to functions.