A confusing array load.

Hi, this is my first post so plz forgive me for any confusion. I have a C++ program that is loading in a data file into an array. I believe I have a good understanding on how I’m suppose to do this and what it is suppose to do. The only problem I’m having is when I load in the arrays it’s not putting in the information from the data file in. Here’s the program. Thank you

#include<iostream>
#include<fstream>
using namespace std;

void main()
{

int i,numstd=0,c=0;
char test[21],ans[21],idno[12];
ifstream finans,fintest;
ofstream fout;
finans.open("G:\\C++\\Student Grading\\Answers.dat");
fintest.open("G:\\C++\\Student Grading\\Test.dat");
fout.open("G:\\C++\\Student Grading\\Graded Test.txt");
finans>>ans;
fintest>>idno>>test;

while(!fintest.eof())
{
fout<<"student Id number \t\t\t Correct"<<endl;
fout<<idno<<" \t\t\t ";

for(i=0;i<=19;i++)
{
if(test[i]==ans[i])
c++;
}
fout<<c<<endl;
fintest>>idno>>test;
numstd++;
}
fout<<"Number of students taking test "<<numstd<<endl;
cout<<"done";
}
Last edited on
Topic archived. No new replies allowed.