|
|
|
|
|
|
|
// 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 GetNames( /* out */ String10 name[] ) // Array of candidate
// names
// Reads the list of candidate names from standard input
// Postcondition:
// The user has been prompted to enter the candidate names
// && name[0..NUM_CANDIDATES-1] contain the input names,
// truncated to 10 characters each
{
int candidate; // Loop counter
cout << Enter the names of the candidates, one per line,
<< endl << in the order they appear on the ballot.
<< endl;
for (candidate = 0; candidate < NUM_CANDIDATES; candidate++)
{
// Invariant (prior to test):
// name[0..candidate-1] have been read
// && 0<= candidate <= NUM_CANDIDATES
|
|
|
|
|
|