Trying to do a rank based voting algorithm. Rank tells order of voter preference. For example if rank is 0, this is the first choice of the voter. I'm trying to save the order of names to the array but it doesn't work.
Error is at the ranks[rank] = name;
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;
}
Your are trying to store a String value in int array.
Either change the type of ranks array to String or change type of name to int.