I am trying to write a program that reads lines from a file that contains a person's name, team color, and score from a baseball league. Need to sort the input into two parallel arrays, figure out which team scored more, then print the data of the team that scored more.
I can't figure out:
How to read the file because doing
getline(member, team, score)
isn't working (there are no spaces). I declared variables and set to zero, but do I need to do a prototype too?We need to sort the file into the parallel arrays using an
if
statement inside awhile
loop, so it would be:if(team == color)
, then it would need to put the score in one array, and the member name in the other for that color. But no idea how to write this out, since I'm not printing anything and just want to store it, and then sum the scores. Then I need to increase accumulator for each, but again not sure how to do that with multiple teams.