my professor gave a .o file and we are supposed to write a function that links to his file in ssh.
his code is
struct grades
{ int lab;
int prog;
int mid;
int final;
char name[10];
}
void fillArray(grades a[ ], int & num);
these two are given and i am supposed to write a c++ in linux that reads the file and calculate final grade for each students where there are 50 students.
my code is so far
#include <iostream>
#include <string>
#include<fstream>
#include <cmath>
using namespace std;
struct grades
{
int lab;
int prog;
int mid;
int final;
char name[10];
};
void printScore(grades[], const int);
void fillArray(grades a[ ], int & num);
int main()
{
int countStd;
ifstream fin;
fin.open("lab2.o"); //read txt file
if(fin==NULL)
cout<<"Error";
fin>>countStd;
// cout<<countStd;
for(int i=0; i< countStd; i++)
{
string name;
int lab, prog, mid, final;
fin >> name >> lab >> prog >> mid >> final;
fillArray(grades[i], name, lab, prog, mid, final);
}
printScore(grades,countStd);
return 0;
}
void fillArray(grades& a, const string name, const int s1, const int s2, const int s3, const int s4)
{
s.name = name;
s.lab = s1;
s.prog = s2;
s.mid = s3;
s.final= s4;
s.finalgrade = s1*(.2)+s2*(.2)+s3*(.3)+s4*(.3);
}//storeScore
void printScore(grades a[],const int count)
{
cout<<"\tname \t"<<"\tquiz"<<"\tlab"<<"\tmid"<<"\tfina…
cout<<"*********************************…
for(int i=0; i<count; i++)
{
cout<<a[i].name<<"\t"<<a[i].lab<<"\t"<<a…
cout<<a[i].mid<<"\t"<<a[i].final<<"\t"<<…
}//for
}//printScore
and I get many errors.
can anybody help me with this?