When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
19 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
fstream infile;
infile.open("StudentScores.txt");
if(infile.is_open()){
cout << "File Opened!" << endl;
} else {
cout << "Error opening file!" << endl;
}
while(!infile.eof()) {
cout << "In Loop!" << endl;
numStudents++;
cin >> studentList[numStudents].name >> studentList[numStudents].score;
cout << "SET" << studentList[numStudents].name << studentList[numStudents].score;
if (studentList[numStudents].score > maxScore){
maxScore = studentList[numStudents].score;
cout << "maxscore" << studentList[numStudents].score;
}
totalScore = totalScore + studentList[numStudents].score;
cout << totalScore << endl;
}
infile.close();```
im getting the "File Opened!" cout and the "In Loop!" cout but not the set or any of the others
idk, not enough info
no main function, can't compile and run it
what is studentList, where does it come from, what does it look like
what is totalScore, all the same questions
I can guess at some of this stuff
but I don't want to guess
it's not reasonable to ask us to guess
yeah my bad
even if I guess, maybe you made a typo
okay so basically the struct im using is
struct student
{
string name;
int score;
};```
I don't want "basically"
just post reasonably complete code
you can post multiple files on https://wandbox.org including your data text file
or you could copy paste the contents of your data into a stringstream such that you can reproduce it here with the server bot