Na podstawie komunikatu błędu wygląda na to, że używasz gcc/MinGw.
Zmień ustawienia kompilatora i dodaj flagi: -Wall -Wextra -pedantic -Werror
, to wtedy ten kompilator daje jaśniejsze wyjaśnienie co jest nie tak:
<source>: In function 'int main()':
<source>:11:5: error: this 'for' clause does not guard... [-Werror=misleading-indentation]
11 | for (int i=0; i<5; i++);
| ^~~
<source>:12:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
12 | {
| ^
<source>:14:20: error: 'i' was not declared in this scope
14 | cin>>oceny[i];
| ^
cc1plus: all warnings being treated as errors
Compiler returned: 1
https://godbolt.org/z/hMearo37W
Włącz te flagi, bo te ostrzeżenia wykrywają większość błedów popełnianych przez początkujących.
W niektórych miejscach ostrzeżenia będą nadgorliwe, ale nie powinno to być dla ciebie bolesne.
Bardziej współczesna forma tego kodu (bez używania std::array
):
int main()
{
for (auto& ocena : oceny)
{
cout << endl << "Podaj ocene: ";
cin >> ocena;
}
return 0;
}