My program reads an id, math and English score from a file. the math is stored in math[] while English is stored in eng[]. These scores are then passed onto a function which determines the letter grades for each score.
My issue is that the everything but the last two scores are being read inaccurately. I can't seem to find the problem.
In mathSearch(...) and engSearch(...) you are doing the same. You just evaluate the last field of the array (since g is constantly overwritten). In this context it doesn't make sense that math or eng are arrays at all.
Line 88 does not determine the end of file. The stream does not set id to 0 in that case. So change line 88 to:
while(in>>id){ // Note that the expression in>>id returns false in case of an error like eof
The file is terminated by a 0 in the id location, that's why its while(id!=0), so it doesn't read the zero. The reason eng and math are arrays is so that I can use pointers (g1=mathSearch(&math[0])). Judging by my output, the last two fields are working. What am I doing wrong that gives me this output?
Id Maths Grade English Grade
-------------------------------------
3000 54 F 52 F
2500 80 F 83 F
3200 43 F 85 F
4500 25 F 89 F
3300 90 F 89 F
4600 18 F 12 F
1200 32 F 19 F
1900 44 F 68 F
2300 67 C 92 A
4000 88 B 23 F
Well, only the last check will be successful because you check in mathSearch() and engSearch() only for the last element in the array. You need to understand what the loops are doing there.
All other checks work by accident since the last element in the arrays contain arbitrary values (because not initialized) at that time.