< previous page page_803 next page >

Page 803
void GetEntry( EntryType& );
void GetName( EntryType& );
void GetPhoneNumber( EntryType& );
void Insert( EntryType[], int&, EntryType );
void OpenForOutput( ofstream& );
void Search0rd( EntryType[], EntryType, int, int&, Boolean& );
void WriteEntries( const EntryType[], int, ofstream& );

int main()
{
    EntryType addressBook [MAX_FRIENDS ]; // Array of friends' records

    int       length =0;        // Number of entries in addressBook
    EntryType entry;            // Current record being entered
    char      response;         // Response character from keyboard
    ofstream  friendFile;       // Output file of entries

    OpenForOutput(friendFile);
    if ( !friendFile )
        return 1;
    do
    {

        GetEntry(entry);
        cout << Is this entry correct? (Y or N) ;
        cin >> response;
        if (toupper(response) == Y)
            Insert(addressBook, length, entry);
        cout << Do you wish to continue? (Y or N) ;
        cin >> response;
        cin.ignore(100, \n);

            // Invariant:
            //     addressBook[0..length-1] contain entries
            //     as input from the user
            //  && 0 <= length <= MAX_FRIENDS

     } while (toupper(response) == Y && length < MAX-FRIENDS);
     if (length ==)
         cout << Address book is full. << endl;
     WriteEntries(addressBook, length, friendFile);
     return 0;
}

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

 
< previous page page_803 next page >