Electrical and Computer Engineering
8 of 19
UAH
CPE 112
Implementation
•    OpenForInput(voteFile);
•    if ( !voteFile )
•        return 1;
•    OpenForOutput(reportFile);
•    if ( !reportFile )
•        return 1;
•
•    GetNames(name);
•    ZeroVotes(votes);
•
•    // Read and tally votes
•    voteFile >> precinct >> candidate;
•    while (voteFile)
•    {
•        votes[precinct-1][candidate-1]++;
•        voteFile >> precinct >> candidate;
•    }