I've been trying to make this work, the text file is called "grades", and this the numbers I'm given by the instructor in this file:
44 55 77 88
79 88 100 99
77 99 98 99
100 88 89 100
55 56 40 77
100 100 99 95
88 84 87 88
96 97 99 100
30 44 77 55
79 77 88 0
54 52 60 77
88 77 88 77
44 77 10 95
My code:
i suspect that "Student #1's grade is: 2890246 A" is a result of garbage values contained in the arrays. A likely cause might be that the file is not opened properly.
Try inserting at line 14 (just after opening the file):
1 2 3 4
if (!inFile.is_open())
{
cout << "Error: file is not open" << endl;
}
Also, echoing the comment from jlb, it looks as though you only ever need to deal with 4 grades at a time, so just one array int studentGrades[4]; would suffice.
If you only specify a filename, it assumes that the file is in the same directory as the executable. (Note that this might not be true while running the program through some IDEs, if this is the case, then try copying the file to both where you have the source code, and to the directory with the executable, if you aren't sure which it's trying to get resources from)