You are not checking that the file opens properly
you still have a function prototype for a compare function you are not using
You don't need an answers array.
The loop on line 84-85 is not needed and will output garbage because you never put anything into the array.
Your loop on line 79 is wrong if you are going to use a counting loop consider using a for loop
and whats with the + on line 127? this is a syntax error that should have been fixed before posting
I have solved my problem opening the file, and I think I have most everything corrected that you said to. When I run it now, it says that 50 questions were answered incorrectly. There are only supposed to be 20 answers. I think the problem is in the comparison of the two arrays.
#include <iostream>
#include <fstream>
usingnamespace std;
void getRscore(char[], int);
void getBscore(char[], int);
constint SIZE=20;
int main ()
{
int amountwrong;
char studentanswers[SIZE];
char correctanswers[SIZE];
char wrong[SIZE];
int countdex=0;
getRscore(studentanswers, SIZE);
getBscore(correctanswers, SIZE);
for (int index = 0; index<SIZE; index++)
{
while (studentanswers[index]!=correctanswers[index])
{
wrong[countdex]=studentanswers[index];
countdex++;}}
cout<<"The student answers have been pulled from their file and compared to \n";
cout<<"the correct answers. The amount of answers that were wrong is: " <<countdex <<endl;
cout<<"The incorrect answers are as follows: ";
for (int count=0; count<countdex; count++)
cout<<wrong[count];
system ("pause");
return 0;
}
void getRscore(char score[], int SIZE)
{
ifstream Answers;
Answers.open("StudentsAnswers.txt");
if (Answers)
{
while (Answers)
{for (int count=0; count<20; count++)
Answers>>score[count];}
Answers.close();
}
else
{cout<<"The file 'StudentAnswers.txt.' did not open correctly."; }
}
void getBscore(char Score[], int SIZE)
{
ifstream answers;
answers.open("CorrectAnswers.txt");
if (answers)
{
int count=0;
while (count<SIZE && answers >> Score[count])
count++;
answers.close();}
else
{"The file 'CorrectAnswers' did not open correctly";}
}