The function I am working on is to read in a first name, last name, and four float test scores from a file. I have used the cin and cout operators to check that everything is reading in properly for the first iteration through the while loop. I am checking to make sure that the first name is not the same as "No", which is the sentinel in this case. I have attached my read function, but can easily attach other information that may be necessary.
void ReadInput(ifstream &infile, char *First[], char *Last[], float scores[50][5], int &REU, int &CEU)
//Recieves - the input file, array of first names, last names, array of test scores, and rows and columns used
//Task - reads in the names and test scores from a file
//Returns - filled arrays of first and last names and test scores
//cout << "now in ReadInput " << endl;
char *newPtr;
char first[15], last[15];
int i;
float score;
REU = 0;
infile >> ws;
infile.getline(first,15); //read first name from file
while(strcmp(first,"No ") != 0) // read in names and test scores until "No More"
{
newPtr = new char[15];
strcpy(newPtr, first);
First[REU] = newPtr;
infile >> ws;
infile.getline(last,15);
newPtr = new char[15];
strcpy(newPtr, last);
Last[REU] = newPtr;
CEU = 0; //Initialize the columns used for use in the next row
for(i=0; i<4; i++) //loop through each column in file
{
infile >> scores[REU][i]; //read in the test score
}
REU++;
infile >> ws;
infile.getline(first,15);
CEU=i;
}
cout << "Now Leaving Read" << endl;
cin.ignore();
return;
}