Structures and Array HELP PLEASE

I'm trying to construct a program where I grab a text file from the computer and use ifstream to input it into the program. There would be two text files containing 20 questions and another with 20 answers. I an also using a struct that has three fields and an array of such struct.

Please help, there are errors and I cannot figure out where or what to fix.

Thank you!

_______________________________________________________________________________

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

struct Quiz{
string question;
char key;
char response;
};

const int MAX = 20;
void openInputFile(ifstream &input, const string & message);
int fillQuestions(Quiz qz[], ifstream & in);
int fillAnswersKeys(Quiz qz[], ifstream & in);
void fillResponses(Quiz qz[], int len);
int gradeResponse(const Quiz qz[], int len);
void printAnswersAndResponses(const Quiz qz[], int len);


int main()
{
cout << fixed << showpoint << setprecision(2);

cout << "Driver's License Practice Exam" << endl;
cout << "Questions are multiple choice" << endl;

Quiz qz[MAX];

ifstream in;
openInputFile(in, "message");
int len = fillQuestions(qz, in);
string message[MAX] = {};


char response[MAX] = {};
fillResponses(qz, len);
for (int i = 0; i < MAX; i++)
{
cout << qz[i].response << endl;
}


int points = 0;
points = gradeResponse(qz, len);
printAnswersAndResponses(qz, len);


cout << "You scored " << points << " out of total " << MAX << " points." << endl;

double percent = 100 * double(points) / MAX;

if (percent >= 60.0)
{
cout << "You passed the test." << endl;
}
else
{
cout << "You failed the test." << endl;
}

printAnswersAndResponses(qz, len);
in.close();

return 0;


}

void printAnswersAndResponses(const Quiz qz[], int len)
{


cout << "Here are the correct answers and your responses.\n" << endl;
cout << setw(55) << left << "Question" << setfill(' ') << setw(18) << left << "Correct Answer" << setfill(' ') << left << setw(15) << "Your Response" << endl;

for (int i = 0; i < len; i++)
{
cout << setw(55) << left << qz[i].question << setfill(' ') << setw(18) << left << qz[i].key << setfill(' ') << left << setw(15) << qz[i].response << endl;
cout << "Press enter key to see next entry" << endl;
system("pause");
}
}



void fillResponses(Quiz qz[], char response[], int len)
{
cout << "Enter the correct letter response out of A, B, C, or D." << endl;

for (int i = 0; i < len; i++)
{
cout << qz[i].question << endl;
cin >> qz[i].response;
}
}

int fillAnswerKeys(Quiz qz[], ifstream & inA)
{
char ch = ' ';
int i = 0;

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

int fillQuestions(Quiz qz[], ifstream & in)
{
char ch = ' ';
int count = 0;

while ((ch = in.peek()) != EOF && count < MAX)
{
string temp = "";
getline(in, temp);
qz[count].question = temp;
char ans = false;
in >> ans;
in.ignore(128, '\n');
qz[count].key = ans;
count++;
}
return count;
}
void openInputFile(ifstream & input, const string & message)
{
bool done = false;
string In_File = " ";

while ((!done))
{
input.clear();
cout << "Please input the name of the data file to be read with " << message << " to be read: ";
getline(cin, In_File);
cout << "\nThe file name entered was: " << In_File << endl;
input.open(In_File.c_str());

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

if (input.eof())
{
cout << "The file has not data in it" << endl;
done = false;
input.close();
}
else
{
done = true;
}
}
}
cout << "File" << In_File << " opened has data in it." << endl;

}

int graderesponse(const Quiz qz[], int len)
{
int score = 0;
for (int i = 0; i < len; i++)
{
if (qz[i].key == qz[i].response)
{
score++;
}
}
return score;
}


Next time you post, remember to put your code [code]inside the code tags[/code].

Your problem is that the function headers in your function definitions do not match the function prototypes for the fillResponses and gradeResponse functions.
Topic archived. No new replies allowed.