Help with functions

I'm writing a program for class that requires the use of arrays and functions to write a test with multiple choice. I have put together this code base on separate examples we had in class or from other sources. I have a problem with my fillResponArray function... I cant get the program to continue to the next question. It just works correctly with the first question and when I answer the question and hit enter, it scrolls down thru the questions about two times and never lets me answer any more... I'm not sure what is wrong here..

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

const int MAX = 20;
void OpenFile(ifstream & input, const string & message);
int fillQuesArray(string questions[], ifstream & inq);
int fillAnsrArray(int answers[], ifstream & inq);
void fillResponArray(const string questions[], int response[], int lenQ);
int GradedResponse(const int answers[], const int response[], int len);
void printQuesAnsResponses(const string questions[], const int answers[], const int response[], int len);

int main(){

cout<<"OKLAHOMA DEPARTMENT OF MOTOR VEHICLES\n";
cout<<"DRIVER'S LICENSE TEST\n";
ifstream in;
OpenFile(in, "questions");
string questions[MAX] = {};
int countQ = 0;
int lenQ = fillQuesArray(questions, in);
/*{
for (int i = 0; i < MAX; i++){
cout<<questions[i]<<endl;
}
system("Pause");
}*/
in.close();
ifstream inA;
OpenFile(inA, "answers");
/*{
for (int i = 0; i < MAX; i++){
cout<<questions[i]<<endl;
}
system("Pause");
}*/
in.close();

int answers[MAX];
int countA = 0;
int lenA = fillAnsrArray(answers, inA);

if(countQ != countA){
cout<<"Your questions do not match the answers you submitted.\n\n";
cout<<"The program will end now.\n\n";
system("Pause");
exit(0);
}


int response[MAX];
fillResponArray(questions, response, lenQ);
int score = 0;
score = GradedResponse(answers, response, lenQ);
printQuesAnsResponses(questions, answers, response, lenQ);
cout<<"Your score was "<<score<<" out of 20.\n\n";
double percent = (double(score)/lenQ)*100;

if(percent >= 60.0){
cout<<setw(45)<<right<<"CONGRATULATIONS!!!"<<endl;
cout<<"You recieved a passing score of "<<percent<<"%.\n\n";
cout<<"You can review your test below to correct any defficiencies.";
cout<<"------------------------------------------------------------------\n";
}
else{
cout<<setw(38)<<"WE ARE SORRY..."<<endl;
cout<<"You have failed to recieve a passing score on this exam.\n\n";
cout<<"Please study the material below before you re-take the\n\n";
cout<<"written portion of your DRIVER'S LICENSE test again.\n\n";
cout<<"------------------------------------------------------------------\n";
}

in.close();
system("Pause");
return 0;
}

void OpenFile(ifstream & input, const string & message){
bool done = false;
string InputFile = "";

while(!done){
input.clear();
cout<<"Input the file name that has the test "<<message<<"[Ex. C:\\J\\Q.txt]:\n";
getline(cin, InputFile);
cout<<"You have entered: "<<InputFile<<endl;
cout<<InputFile<<endl;
input.open(InputFile.c_str());

if(input.fail()){
cout<<"The file "<<InputFile<<" does not exist\n";
cout<<"------------------------------------------------------------------\n";
done = false;
}
else{
input.peek();

if(input.eof()){
cout<<"The file has no data inside.\n";
cout<<"------------------------------------------------------------------\n";
done = false;
}
else{
done = true;
}
}
}
cout<<"File "<<InputFile<<" has opened and has data inside.";
cout<<"Let's proceed to the test now.\n";
cout<<"------------------------------------------------------------------\n";

}

int fillQuesArray(string questions[], ifstream & inq){
char ch = ' ';
int i = 0;
//int countQ = 0;

while((ch = inq.peek()) != EOF && i<MAX){
getline(inq, questions[i], '$');
i++;
//countQ++;
}
return i;
}

int fillAnsrArray(int answers[], ifstream & inA){
char ch = ' ';
int i = 0;
//int countA = 0;

while((ch = inA.peek()) != EOF && i < MAX){
inA>>answers[i];
i++;
//countA++;
}
return i;
}

void fillResponArray(const string questions[], int response[], int lenQ){
cout<<"We will begin the test now. Please only respond with A, D, C, or D\n\n";
cout<<"as your answer. !!CAPITAL LETTERS ONLY!!\n";
cout<<"------------------------------------------------------------------\n";

for(int i = 0; i < lenQ; i++){

cout<<questions[i]<<" : ";
cin>>response[i];
}
}

int GradedResponse(const int answers[], const int response[], int len){
int score = 0;
for(int i = 0; i < len; i++){
if(answers[i] == response[i]){
score++;
}
}
return score;
}

void printQuesAnsResponses(const string questions[], const int answers[], const int response[], int len){
cout<<setw(55)<<right<<"OKLAHOMA DRIVER'S LICENSE TEST"<<endl;
cout<<setw(55)<<left<<"QUESTIONS"<<setfill(' ')<<setw(18)<<"Correct Response"<<setfill(' ')<<setw(15)<<"Your Answer"<<endl;
cout<<"------------------------------------------------------------------\n";
for(int i = 0; i < len; i++){
cout<<setw(55)<<questions[i]<<setfill(' ')<<setw(18)<<answers[i]<<setfill(' ')<<setw(15)<<response[i]<<endl;
cout<<"------------------------------------------------------------------\n";
}
}


Any help figuring this out would be greatly appreciated! I'm still a noob by the way, so I'll ask that you keep it simple! HA

Thanks
Topic archived. No new replies allowed.