是在第二个for循环那报错了,但是不知道是什么错误,求指导
struct Student
{
string stuName;
int score;
};
struct Teacher
{
string tName;
Student stuArray[5];
};
void allocateSpace(Teacher tArray[] , int len)
{
string teacherName = "Teacher_";
string studentName = "Student_";
string nameSeed = "ABCDE";
for (int i = 0; i < len; i++)
{
tArray[i].tName = teacherName + nameSeed[i];
for (int j = 0; j < 5; j++)//这里报错了
{
tArray[i].stuArray[j].stuName = studentName + nameSeed[j];
tArray[i].stuArray[j].score = 100;
}
}
}
void printInfo( Teacher tArray[], int len)
{
for (int i = 0; i < len; i++)
{
cout << "教师姓名:" << tArray[i].tName << endl;
for (int j = 0 ; j < 5 ; j++)
{
cout << "\t学生姓名:" << tArray[i].stuArray[j].stuName << " 分数: " << tArray[i].stuArray[j].score << endl;
}
}
}
int main()
{
Teacher tArray[3];
//传入参数
int len = sizeof(tArray) / sizeof(tArray[0]);
allocateSpace(tArray, len);
//打印信息
printInfo(tArray, len);
system("pause");
return 0;
}
```c++
```