-
Arrays in structures
I am new to C++, obviously, and I have to write a program for a class. The program should be very simple. it asks to make a structure for a Student that includes the students name and a 2x3 array that represents two semesters with three grades each. Please don't fall down laughing when you see my code. Here are my problems. First the nested loop crashes and second I don't think I am correctly formating my cin.getline statments correctly either. Help!!!
void main(void)
{
int Cnt,
d,
e;
do{
for (Cnt = 0; Cnt <= 4; Cnt++)
{
cout << "Please enter the Students Name: ";
cin.getline(Student[Cnt].Name, 29);
if (Student[Cnt].Name == '\0')
break;
for(d = 0; d < 1; d++)
{
cout << "Please enter students grades for semester " << (d + 1);
cin >> Student[Cnt].Grade[d][e];
for(e = 0; e < 2; e++)
{
cout << "Grade #" << e << endl;
cin >> Student[Cnt].Grade[d][e];
}
}
}
}
}
-
well u havent make a structure of that students and grade variables
-
The Structure
I didn't copy and paste the structure so here is what I have
struct Record
{
char Name[30];
int Grade[2][3];
}Student[30]
-
-
structs need a ; at the end -
struct myStruct
{
blah
blah
blah
};
-
> do{
Where's the other end of the loop?
> void main(void)
No. int main(void)