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.
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.