// Print the winner (or winners) of the election
void print_winner(void)
{
int max =0;
for(int i=0; i<candidate_count; i++)
{
if(candidates[i].votes>candidates[i+1].votes)
{
max=candidates[i].votes;
}
else if (candidates[i].votes==max)
{
printf("%s\n, winner ", candidates[i].name);
}
}
return;
}
this is my code to print the winner but it is not working, can someone help and tell me where I have gone wrong. The output i get is this-
./plurality bob charlie Number of voters: 2 Vote: bob Vote: bob
For some reason the print statement doesn't get executed. Would really appreciate anyone who could guide me, have been stuck on this for a while. Thank you in advance!