I am supposed to create a function which receives the arrays as parameters and which searches for the student with the highest average of the 3 grades and return to main the location of the student in the array.
The 4 arrays are: Student number(9 digits) Math grade Science grade English grade
And finally, it's supposed to read the data from the file into the array.
File data is:
123456789
60
70
80
987654321
70
80
90
999888777
75
85
65
111222333
55
65
75
444555666
63
73
83
I need help with how to read the file data using the arrays and functions.
This is what I have so far:
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
int findHighest(int Mgrade[5], int Sgrade1[5], int Egrade[5], long Snumber[5]);
main()
{
    int Mgrade[5], Sgrade[5], Egrade[5];
    long Snumber[5];
    char num_from_file;
    ifstream infile;
    char mystring[20];
    int grade;
    infile.open("testdata.txt", ios::in);
    if (infile)
    {
        cout<<"File opened successfully\n";
        {
            do
            {
                infile.get(mystring,21); //(example from other program)
                infile.ignore(80,'\n');// (what should go here instead)
                infile>> grade;//(example from other program)
                infile.ignore(80,'\n');// (what should go here instead)
                if (infile.eof())
                {
                    break;
                }
                cout<<mystring<<'\t'<<grade<<endl<<endl;
                //cout<<'\t'<<num_from_file<<endl;
            }
            while(1);
        }
    }
    else
    {
        cout<<"error opening file";
    }
    infile.close();
    return 0;
}
 
    