< previous page page_804 next page >

Page 804
void OpenForOutput( /* inout */ ofstream& someFile )   // File to be
                                                       // opened
// Prompts the user for the name of an output 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 << Output file name: ;
    cin.get(fileName, 51);
    cin.ignore(100, \n);

    someFile.open(fileName);
    if ( !someFile )
         cout << ** Can't open  << fileName <<  ** << endl;
}

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

void GetEntry( /* out */ EntryType& entry )    // Struct being built

// Builds and returns a complete address book entry

// Postcondition:
//     User has been prompted for a friend's first name, last name,
//     phone number, and birth date
//  && The input values are stored in the corresponding
//     members of entry

{
    GetName(entry);
    GetPhoneNumber(entry);
    cout << Enter birth date as three integers, separated by
         << spaces: MM DD YYYY << endl;
    cin >> entry .month >> entry, day >> entry, year;
}

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

 
< previous page page_804 next page >