dimanche 12 septembre 2021

Expression must have class type but it has type int: Error [duplicate]

hope that you are doing well. New to c++ coding. I couldn't understand the problem in my code.

int scores[]{ 100, 90, 87 };
    int i{ 0 };
    while (i <= scores.size()) {
        cout << scores[i];
        i++;
    }

As per my understanding, i am simply stating that check size of array and if i is less than or equal to scores.size execute it.

The code works perfectly fine, if i place 2 instead of scores.size()

Aucun commentaire:

Enregistrer un commentaire