#include <iostream>
#include <fstream>
usingnamespace std;
void getRscore(char[], int);
void getBscore(char[], int);
char compare(char[], 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("StudentAnswers.txt");
char answers[SIZE];
int count=0;
while (count<SIZE && Answers >> answers[count])
count++;
Answers.close();
}
void getBscore(char Score[], int SIZE)
{
ifstream answers;
answers.open("CorrectAnswers.txt");
char swers[SIZE];
int count=0;
while (count<SIZE && answers >> swers[count])
count++;
answers.close();
}
I'm just going to take a stab at this. Within your functions, make score[] and Score[] into pointers (*score[] *Score[]). This way you can put the values into the arrays that you want the answers to be in. And get rid of answers[] and swers[]. In the while loops, also make sure that they are pointers as well (answers[count] would be *score[count]). Not 100% sure if this is what you do but I'm pretty sure it is.
In your getRscore function you don't check to make sure your file opened successfully. Its possible that you are not inputting the data properly. Also you store the ansers in a local array ansers[]. You do not pass this array back to main so when the function ends the array is destroyed along with the answers. you should be inputting the data into your score[] array. You have similar problems with your getBscore function and I don't see a compare function definition or function call at all.