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

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

    }
}
return false;

}

1

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

Remember,

preferences[i][j];

Is simply,

preferences[row][coloumn];

So, For first preference only

preferences[changing_row][1st_coloumn];

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

| improve this answer | |
1

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

Also tell a bit more about your problem

Thanks.

| improve this answer | |
  • im doing what the format says to do but i cant get it to show correctly – iliketurtlz Jul 16 at 19:40
  • Just tell me your problem or say the function you r working on – Shahroz Ali Jul 16 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 – iliketurtlz Jul 16 at 19:45
  • I am adding another answer check it – Shahroz Ali Jul 16 at 19:46
1
vote

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 😃

| improve this answer | |
  • but how do you single out rank 1 – iliketurtlz Jul 16 at 19:53
  • Posting another answer – Shahroz Ali Jul 16 at 19:55

You must log in to answer this question.

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