Hi im trying to loop through an input file such as:
333 45 56 67
456 80 90 74
...
First number is id, followed by three exam scores..and the "stud.h" is my struct for each piece of data.
My problem is looping through each line of data. Any ideas what im doing wrong?
#include "stud.h"
void ReadRd(ifstream& inFile, StudRd& rd)
{
inFile >> rd.id;
while(inFile){
inFile >> rd.exam1 >> rd.exam2 >> rd.exam3;
inFile >> rd.id;
}
}
void WriteRd(ofstream& outFile, StudRd rd)
{
int i;
outFile << "*~< Student Exam Report >~*" << endl;
outFile << "ID" << setw(10) << "Exam 1" << setw(20)
<< "Exam 2" << setw(20) << "Exam 3" << setw(20)
<< "AVG" << endl;
outFile << "--" << setw(10) << "------" << setw(20)
<< "------" << setw(20) << "------" << setw(20)
<< "---" << endl;
outFile << rd.id << setw(10) << rd.exam1 << setw(20)
<< rd.exam2 << setw(20) << rd.exam3 << setw(20)
<< setprecision(4) << rd.avg << endl;
outFile << "END" << endl;
}