Hi all,
So I'm creating a program that will calculate the grade average of students in a class.
I'm suppose to read a file into an array and I'm having problems with that.
Here is part of my code.
//Output Func
void StudentStat::Output()
{
for (int i = 0; i < Size; i++)
{
cout << " " << " " << " ";
for (int j = 0; j< Size; j++)
{
cout << " " << Names[i] << " " << Scores[j] << endl;
}
}
}
//Input Func
void StudentStat::Input(int val[])
{
Size = val[0];
int count = 1;
for(int i = 0; i < Size; i++)
for(int j = 0; j < Size; j++)
{
Names[i] = val[count++];
Scores[j] = val[count++];
}
}
//and here is the main
ifstream ProgEven ("bababa.dat");
int main()
{
int temp[20]; //Values not set to null
int sqsize;
StudentStat *Msq = new StudentStat();
while (!ProgEven.eof())
{
ProgEven >> temp[0]; //The size is at temp[0];
sqsize = temp[0];
sqsize *= sqsize;
for (int i = 0; i < sqsize; i++)
ProgEven >> temp[20];
Msq->Input(temp);
Msq->Output();
}
return 0;
}
Thanks for the help