for(m = 0; m < voter_count; m++)
for(t = 1; t < 4; t++)
string name = get_string("Rank %i: ", t);

} bool vote(int voter, int rank, string name) { for (z = 0; z < candidate_count; z++) { if(strcmp(candidates[z].name, ) == 0) {

return false;


3 Answers 3


To check the name of the candidate in the 1st preferred coloumn only



Is simply,


So, For first preference only


Inside this cell is just a number, Use it to match the name of the candidate.

  • thanks it helped Jul 16, 2020 at 20:27

Please share the code correctly so that I can help you as quickly as possible.

Also tell a bit more about your problem


  • im doing what the format says to do but i cant get it to show correctly Jul 16, 2020 at 19:40
  • Just tell me your problem or say the function you r working on Jul 16, 2020 at 19:43
  • my problem is i dont know ho to compare the names to what the person puts for rank 1 i dont know how to just single out that rank Jul 16, 2020 at 19:45
  • I am adding another answer check it Jul 16, 2020 at 19:46

This function inputs a string a search for the names in the table of candidates, it returns true once the name has been founded or matched i.e == 0

But how?

Use for-loop to iterate through the candidate_count and check the name of the candidate by using strcmp declared in string.h

if (strcmp(candidate[i].names, name) == 0)

return true;


In this way iterate through every Candidate and try to match the name if yes then return true else return false

If I helped you be sure to tick the answer to keep other smiling too 😃

  • but how do you single out rank 1 Jul 16, 2020 at 19:53
  • Posting another answer Jul 16, 2020 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .