I need to read this into a arrays.
123455 45 67 87 69 98
3456787 67 98 34 54 67
456778 87 76 89 76 34
344568 65 78 76 45 98
56789 98 76 45 34 54
Here is the code I have
void getGrades(double exam[], int studentId[])
{
ifstream inFile;
inFile.open("student.txt");
for (int i = 0; i < 5; i++)
{
inFile >> studentId[i];
for (int j = 0; j < 5; j++)
{
inFile >> exam[j];
}
}
}
void printGrades(double exam[], int studentId[])
{
for (int i =0; i < 5; i++)
{
cout << "student id" << studentId[i] << endl;
for (int j =0; j < 5; j++)
{
cout << "grades" << exam[j] << endl;
}
}
}
And here is the out put I get
student id123455
grades98
grades76
grades45
grades34
grades54
student id3456787
grades98
grades76
grades45
grades34
grades54
student id456778
grades98
grades76
grades45
grades34
grades54
student id344568
grades98
grades76
grades45
grades34
grades54
student id56789
grades98
grades76
grades45
grades34
grades54
So my loops are working in reading the student id's, I'm not seeing what I'm doing wrong for the nested loop.