I think it is relating to the fact that infile and outfile are not defined within the scope of the ReadAnswers() function. Fix that and see if that was causing the other errors.
I need urgent help!! I am still working on the problem and have found problems in reading the data for example for the following set of data which is student's ID followed by 20 answers (its not a code but rather a text file-otherwise its too long to fit the screen):
1 2 3 4 5
2061090 B D A C C A B C C A B D D A B C A B D B
2061143 B C A C B A B C C A B A D A B C A B D A
2071233 B C A C B B A A C A A A D A B C A A D D
2081251 A A A C B B A A C A A A D A B C A A D D
2071217 B D A A C A B A C D B C D A D C C B D A
I came up with the following code but i think im doing something wrong:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void ReadStudents(char array[5][], ifstream& infile)
{
for (int i =1; i<5; i++)
{ int ID;
infile>>ID>>endl;//to read the ID first
for (int j=0; j<20; j++) // this loop reads the answers of each student from the text file
{
infile>>AnswersOfStudents[i][j];
}
}
}
how can i read only the students answers should I initialize the counter to 1 rather than zero and about the inner loop-its counter would change too right-To put it simply, How can I skip the students ID and just store the answers into a two a two dimensional array - im confused!
note: For the above problem, I just figured it out-I have to pass the infile and outfile by reference