My program behave correctly when i try it manually but it fails in check50. It returns " :( print_winner identifies Alice as winner of election " print_winner function did not print winner of election.
// Print the winner (or winners) of the election
void print_winner(void)
{
int max = 0;
{
for (int i = 0; i < candidate_count-1; i++)
{
if ( candidates[i].votes > candidates[i+1].votes)
{
max = candidates[i].votes;
}
else
{
max = candidates[i+1].votes;
}
}
for (int i = 0; i < candidate_count; i++)
{
if (candidates[i].votes == max)
{
printf ("%s\n", candidates[i].name);
}
}
}
return;
}
Thanks in advance for any help.