Hello /g/. I want to write a program in C that pulls questions from a list as well as answers for a trivia game. The program would display a random question from a list of questions I premade. Then ask the user for an answer. I would take the input from the user and compare it to the corresponding answer from the list. The thing is I don't know how I would go about doing this. Can I make the list of questions in notepad and pull it from there? Can i create a spreadsheet for the questions and answers in a database and pull the questions randomly from there? How would I go about making this program? Any help and answers will be greatly appreciated.
>>53648410
put it in a .html file and then parse it
>>53648410
How newby is newby? From your range of questions I would imagine brand new, and if that's the case you're starting with a project that might be a bit out of your league.
It's not that the task at hand is hard, it's just the fact that you don't know simple things like reading from files or, perhaps, populating arrays and randomly selecting from them. Try some elementary programming challenges for C that focus on your particular needs, piece by piece, and then go for there
>>53648518
>go for there
Go from there.*
>>53648480
>>53648518
Yes completely new. Thanks a lot.
>>53648410
You could create a library of question objects. The object would be something like string question string answer.
You use some kind of random function to make the array random and then pull each question one at a time.
If you want the question to be multi choice. You give the question objects 3 fake answers.
If you make it multi choice you won't have to handle misspelling and complex answers. Just a b c or d
>>53648480
I think html might be a bit much to ask for parsing for a newby. I think using a csv would be better and wouldn't require some external C-html lib.
<question>, <answer>
What is the powerhouse of the cell?, mitochondria
Is OP always gay?, yes
>>53648410
You can write your QA in a spreadsheet and export it as a CSV file.
>>53650553
>>53652473
Screw this. Put in in a record jar.Planet: Mercury
Orbital-Radius: 57,910,000 km
Diameter: 4,880 km
Mass: 3.30e23 kg
%%
Planet: Venus
Orbital-Radius: 108,200,000 km
Diameter: 12,103.6 km
Mass: 4.869e24 kg
%%
OP, make sure you keep your parsing logic completely separate from everything else. This is a really good case-study for Unix software engineering skills.