< previous page page_1016 next page >

Page 1016
//******************************************************************
// SortWithPointers program
// This program reads personnel records from a data file,
// sorts the records alphabetically by last name,
// and writes them to the standard output device
// Assumption: The input file contains at most 1000 records
//******************************************************************
#include <iostream.h>
#include <fstream.h>    // For file I/O
#include reclist.h    // For RecordList class
#include bool.h

void OpenForInput( if stream& );

int main()
{
    RecordList list;            // List of personnel records
    ifstream   masterFile;      // Input file of personnel records
    Boolean    outOfMem;        // True if not enough memory for
                                //   all input records

    OpenForInput(masterFile);
    if ( !masterFile )
        return 1;

    list.ReadAll(masterFile, outOfMem);
    if (outOfMem)
        return 1;

    list.SelSort();
    list.PrintAll();
    return 0;
}

//******************************************************************

void OpenForInput( /* inout */ if stream& someFile )     // File to be
                                                         // opened
// Prompts the user for the name of an input file
// and attempts to open the file

{
   .
   .     (Same as in previous case studies)
   .
}

 
< previous page page_1016 next page >