Question
Hi, I am trying to create a function to read the file and instantiate the questions one by one, adding them to the questions vector.
Hi, I am trying to create a function to read the file and instantiate the questions one by one, adding them to the questions vector. How can I add to my code and do this?
My file is questions.txt with contexts of:
206 How many bones are in the average adult human? 2000 How many yards are in a nautical mile? 195 How many countries are in the world? 15 How many hands high must an equine be to be considered a horse, instead of a pony?
Code reading file:
#include
public: void LoadQuestions(string fname) { ifstream questionsFile; questionsFile.open(fname); if (questionsFile.fail()) { cerr << "Can't open "; exit(-1); } } };
I am unsure how to create the vector to store the questions and answers...
i also need to create a function
getNextQuestion()
This function should return a question from the list for use by the Game class, described below.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started