teknique

Untitled

Nov 19th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. void add_county_election_file(std::vector<string> & countyNameVector, std::vector<int> & countyNCount, vector<int> & countyFCount, std::vector<int> & countyOCount, int & NCount, int & FCount, int & OCount)
  2. {
  3. char vote;
  4. string filename;
  5. string countyName;
  6. NCount = 0;
  7. FCount = 0;
  8. OCount = 0;
  9.  
  10. cout << "Enter the county file to process: ";
  11. cin >> filename;
  12. std::ifstream input((filename).c_str());
  13. if(input.is_open())
  14. {
  15. input >> countyName;
  16. //adds the county name to the vector of names
  17. countyNameVector.push_back(countyName);
  18. while(input >> vote)
  19. {
  20. if(vote == 'N' || vote == 'n')
  21. {
  22. NCount = NCount + 1;
  23. }
  24. else if(vote == 'F' || vote == 'f')
  25. {
  26. FCount = FCount + 1;
  27. }
  28. else
  29. {
  30. OCount = OCount + 1;
  31. }
  32. }
  33. //adds the count of party votes for the current file to a vector
  34. countyNCount.push_back(NCount);
  35. countyFCount.push_back(FCount);
  36. countyOCount.push_back(OCount);
  37. }
  38. else
  39. {
  40. cout << endl;
  41. cout << "File not found!" << endl;
  42. cout << endl;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment