|
|
|
|
|
|
|
OpenForInput(file2);
if ( !file2 )
return 1;
OpenForInput(file3);
if ( !file3 )
return 1;
OpenForOutput(masterFile);
if ( !masterFile )
return 1;
GetRecords(file 1, firstList);
GetRecords(file2, secondList);
Merge(firstList, secondList, tempList);
GetRecords(file3, firstList);
Merge(firstList, tempList, masterList);
Write(masterList, masterFile);
return 0;
}
//******************************************************************
void OpenForInput( /* inout */ ifstream& someFile ) // File to be
// opened
// Prompts the user for the name of an input file
// and attempts to open the file
// Postcondition:
// The user has been prompted for a file name
// && IF the file could not be opened
// An error message has been printed
// Note:
// Upon return from this function, the caller must test
// the stream state to see if the file was successfully opened
{
char fileName[51]; // User-specified file name (max. 50 chars)
cout << Input file name: ;
cin.get(fileName, 51);
cin.ignore(100, \n);
someFile.open(fileName);
if ( !someFile )
cout << ** Can't open << fileName << ** << endl;
}
//******************************************************************
|
|
|
|
|
|