I am trying to write a program that will read multiple choice questions from a text file that contains a bank of 5 questions. Every time the user opens the program, it will give them the questions in a random order. After the user is done, it should give the user a final score.
Below is my code. I am having issue formating the output the way I want it to display. I would like it to display exactly how I have it in my text file.
In my text file the format is like this:
1. What is the answer to 2+3?
a. 6
b. 9
c. 5
d. 2
When i run the program, it only read the 1st line.
My idea is to create a struct for the actual quiz entry, implement reading them from the file and store them in a vector so you can easily get a random entry.
1 2 3 4 5 6 7 8 9 10 11 12 13
struct QuizEntry
{
std::string question;
int answers[4];
};
std::istream& operator>>(std::istream& is, QuizEntry& entry)
{
// code to read
return is;
}
std::vector<QuizEntry> Quiz;