#include <iostream> //2
using namespace std;
struct student {
int id;
int name[10];
int sc[3];
int total;
double ave;
};
void main() {
struct student ST[5];
int i, j;
for (i = 0; i < 5; i++) {
cin >> ST[i].id >> ST[i].name;
for (j = 0; j < 3; j++)
cin >> ST[i].sc[j];
ST[i].total = ST[i].sc[0] + ST[i].sc[1] + ST[i].sc[2];
ST[i].ave = ST[i].total / 3.0;
}
cout <<"Number name Korean English Math total average\n";
for (i = 0; i < 5; i++)
cout << ST[i].id << "\t" << ST[i].name << "\t" << ST[i].sc[0] << "\t" << ST[i].sc[1]
<< "\t" << ST[i].sc[2] << "\t" << ST[i].total << "\t" << ST[i].ave << endl;
}
Severity Code Description Project File Line Display Error (Suppression) Status Error C2679 Binomial '>>': No operator using the form 'int [10]' as right operand or no transformation allowed.
What's the reason for the error?
c++
inta;
and intb[10];
have different structures.
In addition, cin
is not supported for that form (intb[10]).
In the above structure declaration, it must be char name[10];
instead of int name[10];
. This will run normally.
Line 14 sin >> ST[i].id >> ST[i].name[i];
© 2024 OneMinuteCode. All rights reserved.