mardi 11 décembre 2018

C++: Cannot compare double from an array of structures to another double in if function

int i = 0, gr = 1; double otlichen6 = 5.5;

for (gr = 1; gr <= 4; gr++)
{
    int nqmaotl = 1;
    cout << "Otlichnici ot " << gr << " grupa: " << endl;
    for (i = 0; i < n; i++)
    {
        int nqmaotl = 1;
        if (students[i].srusp >= otlichen6 && students[i].grupa = gr)
        {
            cout << i + 1 << ". " << students[i].ime << "   " << students[i].faknom << "   " << students[i].spec << "   " << students[i].grupa << "   " << students[i].srusp << endl;
            nqmaotl = 0;
        }

The problem is with the first comparison in the if function. I cannot compare students[i].srusp (where students is an array of structures, and each of those structures contain the element srusp which is double type) with double otlichen6 which equals 5.5 , even when I just compare students[i].srusp with 5.5 it still doesn't work. The errors I get are: 1. E0137 expression must be a modifiable lvalue
2. C2106 '=': left operand must be l-value
I switched their places and it still says "left operand must be l-value), which I have no idea what it means.

Aucun commentaire:

Enregistrer un commentaire