0

I keep getting the error "expression result unused" on the line with preferences[i][j]; . I've tried reinitializing the j and the i variable in the loop in different ways but nothing I've tried seems to work.

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(name, candidates[j].name) == 0)
            {
                preferences[i][j];
            }
        }
        return true;
    }
    return false;
}
0

Essentially you're not doing anything with preferences[i][j]; if you remove the line, nothing different happens in your function.

Do you want to check its value, or perhaps assign a new value to it?

PS. Based on the evaluation conditions in your loops, it is quite likely that your function will always return false immediately.

You must log in to answer this question.

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