I am trying to load an exam and have it read from a separate .txt file. I don't know how to make it work. I am using Cygwin and have code and have a .txt file. I made it in wordpad. It wont talk to the source code. Do I not use wordpad. I see it using excel a lot but I don't know how that works either. I want the code to load an exam and ask the user questions. The user can tell the code which question to ask then it will make the question based on the .txt file. Here is the code I am using.
using namespace std;
Question(string theQuestion, int pointValue)
question = theQuestion;
value = pointValue;
string getQuestion(string qu)
question = qu;
cout << "\t" << question << endl;
int getValue(int val)
value = val;
cout << "Worth " << value << " points" << endl;
virtual string printOptions()
virtual string getAnswer()
}; //end question class
else if (questionType == "MC")
infile >> numOptions;
for (int j = 1; j <= numOptions; j++)
}//end multiple choice
};//end test bank function
//open test bank file
//error if file can't open
cout << "File could not be opened" << endl;
here is the .txt file.
There exist birds that cannot fly?
Who was the President of the USA in 1991?
George Bush Sr.
The city of Boston hosted the 2004 Summer Olympics?
I just have no idea where to go from here. I have tried changing the int main to work differently but when I am changing my code around I just cause more errors.
oh no I haven't. I think that has been the majority of my problem. I don't know what program to use to try and open it. Would it be in word or excel? Would these programs make a workable program through Cygwin?
Programs like Wordpad don't work with plain text. They create a heavily-marked up version of text that you really don't want to spend the time parsing.
You need a program that creates only text. On Windows, the default program to do that is *cough*Notepad*cough*. You also have another program that can do it — your programming IDE! If you are using Code::Blocks or Geany or Visual Studio or Notepad++ or whatever, use that to create your .txt data file.