Electrical and Computer Engineering
12 of 19
UAH
CPE 112
Implementation
•void GetNames( /*out*/ string name[] )    // Array of candidate
•                                          //   names
•// Reads the candidate names from standard input
•{
•    string inputStr;      // An input string
•    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++)
•    {
•        cin >> inputStr;
•        name[candidate] = inputStr.substr(0, 10);
•    }
•}