|
|
|
|
|
|
|
{
int index; // Loop control variable
for (index = 0; index < length; index++)
// Invariant (prior to test):
// Structs pointed to by ptrList[0..index-1]
// are no longer on the free store
// && 0 <= index <= length
delete ptrList[index];
}
//*****************************************************************
void GetRecord( /* inout */ ifstream& inFile,
/* in */ PersonPtr aPerson )
// Reads one record from file inFile
// Precondition:
// inFile is open for input
// && aPerson points to a valid PersonnelData struct
// Postcondition:
// IF input of the lastName member failed due to end-of-file
// The contents of *aPerson are undefined
// ELSE
// All members of *aPerson are filled with the values
// for one person read from inFile
{
inFile.get(aPerson->lastName, 21);
if ( !inFile )
return;
inFile.ignore(100, \n);
inFile.get(aPerson->firstName, 21);
inFile.ignore(100, \n);
inFile.get(aPerson->address.street, 21);
inFile.ignore(100, \n);
inFile.get(aPerson->address.city, 21);
inFile.ignore(100, \n);
inFile.get(aPerson->address.state, 21);
inFile.ignore(100, \n);
|
|
|
|
|
|