Usually it's done using the <fstream> header.
warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
This warning applies to line 112
stu1.quiz_average = ((stu1.quiz1/10.) + (stu1.quiz2/10.))/2.*.25;
Your quiz_average is declared as an int, but your answer is a double. Try converting your quiz_average to double in your struct record.
I am trying to output this section to the writerecord function
ofstream offers you the << operator, which means that everything you write in a cout, you can write it in an ofstream variable, in the same way. Just have a look at this class: Click Here
Have youu used fwrite()?
No need for a fwrite().
Lucaci Andrew
Practically a Master Poster
649 posts since Jan 2012
Reputation Points: 91
Solved Threads: 91
Skill Endorsements: 12
Change
void gradeAverage(record stu1)
to
void gradeAverage(record &stu1)
and try it again.
And also, what i've ment by the ofstream operator and cout is this:
void writerecord(ofstream& outFile, record stu1)
{
outFile << endl << endl;
outFile << "Quiz 1: " << (stu1.quiz1/10)*100 << "%";
outFile << "Quiz 2: " << (stu1.quiz2/10)*100 << "%";
outFile << endl;
outFile << "Mid-Term Exam: " << stu1.midterm << "/100";
outFile << endl;
outFile << "Final Exam: " << stu1.final << "/100";
outFile << endl;
outFile << "Final Grade: " << stu1.total_grade << "%";
outFile << endl;
outFile << "Letter Grade: ";
if (stu1.total_grade >= 90)
outFile << "A" << endl;
else if (stu1.total_grade >= 80)
outFile << "B" << endl;
else if (stu1.total_grade >=70)
outFile << "C" << endl;
else if (stu1.total_grade >=60)
outFile << "D" << endl;
else
outFile << "F" << endl;
}
But first, you have to call the gradeAverage() function, that the writerecord one.
Lucaci Andrew
Practically a Master Poster
649 posts since Jan 2012
Reputation Points: 91
Solved Threads: 91
Skill Endorsements: 12
Change it in the header also, if using one.
Lucaci Andrew
Practically a Master Poster
649 posts since Jan 2012
Reputation Points: 91
Solved Threads: 91
Skill Endorsements: 12
Post the exact contents of the gradesIn.txt and gradesOut.txt files.
Lucaci Andrew
Practically a Master Poster
649 posts since Jan 2012
Reputation Points: 91
Solved Threads: 91
Skill Endorsements: 12