bool vote(int rank, string name, int ranks[])
{
for (int i = 0; i < candidate_count; i++)
{
if (strcmp(name, candidates[i]) == 0)
{
ranks[rank] = name;
printf("rank was successfuly recorded");
return true
}
}
// TODO
return false;
}
1 Answer
ranks
is an array of integers as declared in the function signature. name
is a string. Recall from the spec [emphasis added]:
ranks[i]
is the index of the candidate who is theith
preference for the voter.