im having a problem this is my first time using structs .. i think its in main

#include <iostream>
#include <iomanip>
#include<fstream>
using namespace std;
const int size=20;
struct studentType

{
string firstname;
string lastname;
int testscore;
char lettergrade;
};
void print(studentType myStudents[]);
void init(studentType myStudents[], ifstream& infile);
void letgrade(studentType myStudents[]);
void testhi(studentType myStudents[]);


int main()
{

ifstream infile;
infile.open("e:\\input.txt");
studentType myStudents[size];

init( myStudents,infile);
letgrade(myStudents);
print(myStudents);
testhi(myStudents);
return 0;
}

void init( studentType myStudents[], ifstream& infile)
{
for(int i=0;i<size;i++)
{
infile>>firstname.myStudents[i]>>lastname.myStudents[i]>>testscore.myStudents[i];
if(testscore>100||testscore<0)
cout<<firstname.mystudents[i]<<" "<<lastname.mystudents[i]<<"invalid test score"<<endl;
}
}
void letgrade(studentType myStudents[])
{
for(int i=0;i<size;i++)
{
if(testscore.myStudents[i]>=90)
lettergrade.myStudents[i]='a';
else if(testscore.myStudents[i]>=80)
lettergrade.myStudents[i]='b';
else if(testscore.myStudents[i]>=70)
lettergrade.myStudents[i]='c';
else if(testscore.myStudents[i]>=60)
lettergrade.myStudents[i]='d';
else
lettergrade.myStudents[i]='f';
}
}

void testhi(studentType myStudents[])
{
string highstudentf;
string highstudentl;
int highscore=0;
for(int i=0;i<size;i++)
{
if (highscore<testscore.myStudents[i])
{
highscore= testscore.myStudents[i];
highstudentf=firstname.myStudents[i];
highstudentl=lastname.myStudents [i];
}
}
cout<<setw(10)<<"student with high score is "<<highstudentf<<" "<<highstudentl<<" "<<highscore<<endl;
}

infile>>firstname.myStudents[i]>>lastname.myStudents[i]>>testscore.myStudents[i]; It should be: infile>>myStudents[i].firstname>>myStudents[i].lastname>>myStudents[i].testscore;]
Replace this everywhere u find it.
Topic archived. No new replies allowed.