Hi if anyone can guide me in the right direction to record name & rank in the preferences array? I don't have any clue how to even utilize the int vote and int rank in the bool parentheses of the function. Just point me in the right direction, I don't know how to record it in the preferences array. TIA <3
bool vote(int voter, int rank, string name)
{
for(int i = 0; i < voter_count; i++)
{
for (int j = 0; j < candidate_count; j++)
{
if(strcmp(candidates[j].name, name) == 0)
{
preferences[i][j]++;
return true;
}
}
}
return false;
Writing it this won't work either
preferences[i][j] = candidates[j].name;
compiler gives error that
runoff.c:138:35: error: incompatible pointer to integer conversion assigning to 'int' from 'string' (aka 'char *') [-Werror,-Wint-conversion] preferences[i][j] = candidates[j].name;
Blockquote