< previous page page_814 next page >

Page 814
//******************************************************************
#include <iostream.h>
#include <fstream.h>    // For file I/O
#include <string.h>     // For strcmp()

const char SENTINEL[] = ZZZZZZZZZZZZZZZ;
const int MAX_RECS = 100;     // Max. no. of records in a file
                              //   (including sentinel record)

typedef char String8[9];      // Room for 8 characters plus \0
typedef char String15[16];    // Room for 15 characters plus \0

struct PhoneType
{
    int     areaCode;     // Range 100..999
    String8 phoneNumber;
};
struct PersonRec
{
    String15  lastName;
    String15  firstName;
    PhoneType phone;
};

void Append( const PersonRec[], const PersonRec[], PersonRec[],
             int&, int&, int& );
void GetRecords( ifstream&, PersonRec[] );
void Merge( const PersonRec[], const PersonRec[], PersonRec[] );
void OpenForInput( ifstream& );
void OpenForOutput( ofstream& );
void Write( const PersonRec[], ofstream& );

int main()
{
    PersonRec firstList[MAX-RECS];    // Records from an input file
    PersonRec secondList[MAX-RECS];   // Records from an input file
    PersonRec tempList[MAX-RECS*2];   // Temporary merged list
    PersonRec masterList[MAX-RECS*3]; // Final merged list
    ifstream file1;                   // Input file
    ifstream file2;                   // Input file
    ifstream file3;                   // Input file
    ofstream masterFile;              // Output file

    OpenForInput(file 1);
    if ( !file1 )
        return 1;

 
< previous page page_814 next page >