More in depth:
here are what the files look like
roster.txt file
0 Jason Jacobs
1 Alyson Andrews
2 Doug Daniels
3 Karen Karnes
grades.txt file <--First number=student id, second number= test id, 3rd number=test score.
0 1 83
0 2 91
0 3 79
2 1 62
3 2 89
2 2 91
2 3 70
3 1 57
3 3 84
Code:
using namespace std;
#include "studenttype.h"
const int SIZE=75;
int main ()
{
studenttype student[SIZE];
ifstream gfile, rfile;
string rfname, gfname;
int read, read2, numberofstudents;
cout<<"Please enter the name of the roster file: ";
getline(cin, rfname);
rfile.open(rfname.c_str());
int i=0;
numberofstudents=0;
rfile>>student[0].id;
while(i<SIZE && (!rfile.eof()))
{
rfile>>student[i].firstname;
rfile>>student[i].lastname;
rfile>>student[i+1].id;
numberofstudents++;
i++;
}
cout<<"Processing roster file...found "<<numberofstudents<<" students."<<endl;
cout<<student[0].id<<" "<<student[0].firstname<<" " <<student[0].lastname<<endl;
cout<<student[1].id<<" "<<student[1].firstname<<" " <<student[1].lastname<<endl;
cout<<student[2].id<<" "<<student[2].firstname<<" " <<student[2].lastname<<endl;
cout<<student[3].id<<" "<<student[3].firstname<<" " <<student[3].lastname<<endl;
cout<<"Please enter the name of the grades file: ";
getline(cin, gfname);
gfile.open(gfname.c_str());
int ctr=0;
gfile>>read;
while(ctr<225 && !gfile.eof())
{
gfile>>read2;
student[read].testid[read2];
gfile>>student[read].testscore[read2];
cout<<student[read].lastname<<", "<<student[read].firstname<<endl;
//here is where im having trouble outputting the code correctly
ctr++;
gfile>>read;
}
again any help at all is appreciated...i've got a while before this is due, i just wanted to get a jump and i've been stuck on this all night.