The assignment is to write a program that reads the contents of the correctanswers.txt file into a one dimensional char array and then reads the contents of another file, containing a student's answers, into a second char array. The program should determine the number of questions that the student missed, and then display the following: (1) a list of questions missed by the students showing the correct answers and the incorrect answers provided by the student for each missed (2) the total number of questions missed (3) the percentage of the questions answered correctly (4) if the percentage of correctly answered questions is 70% or greater, the program should indicate that the student passed the exam. Otherwise, it should indicate that the student failed the exam.
This is what I have so far for the assignment, I just started. However, I am not if there is a way to compare two text files line by line. This is where I am stuck at. So may someone please help me?!!?
Code:#include <iostream> #include <fstream> #include <cstring> using namespace std; int main () { const int SIZE=21; char correctAnswers[SIZE]; char studentAnswers[SIZE]; ifstream inFile; ifstream newInFile; //Open the file CorrectAnswers. inFile.open("CorrectAnswers.txt"); //Read the 20 answers from the file CorrectAnswers for (int count=0; count < SIZE; count++) { inFile >> correctAnswers; } //close the file. inFile.close(); //Open the file StudentAnswers. newInFile.open("StudentAnswers.txt"); //Read the 20 answers from the file StudentAnswers for (int count=0; count < SIZE; count++) { newInFile >> studentAnswers; } //close the file. newInFile.close(); return 0; }