questions.push_back("Question 1. What it \"blue\"?\n\n1) A fruit\n2)A color\n3) A drink");
questions.push_back("Question 2. What is a Ferrari?\n\n1) A car\n2) An animal\n3)A computer");
//...
int question_number = rand() % 37;
//...
cout << questions[question_number] << endl;
int question_number = rand() % 37;questions.size() ; // what are u doing here
cout << questions[question_number] << endl; // might be out of bounds
and how do I put a limit of 100 questions to be outputted but not for the test to end ?
Use a for loop
Also this doesn't seem to be randomizing at all ?
Uhmm, it has only 2 questions.
Btw, you can simply use std::random_shuffle() to shuffle elements in a container.
( if u use rand() u'll have to painfully check if the number returned is not returned already )
And You really need to use structures to organize you data.
@ nvrmnd thanks a lot for the detailed reply I will try this out, obviously
you are well advanced because you know what your talking about
you make it look so easy lol.
I usually have better structure when I am programming a full program
but it could be better in general.
Most of the code is new to me, I have written full tests including random
output of answer order, timer, app to txt, and linking user input to the internet as well as allowing the user to change the color of the cmd by number choice.
error: in C++98 'questions' must be initialized by constructor, not by '{...}'
error: deducing from brace-enclosed initializer list requires #include <initializer_list>
23:5: error: deducing from brace-enclosed initializer list requires #include
<initializer_list>
warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by default]
23:5: error: could not convert '{{"What is blue", {"Fruit", "Color", "Drink"}, '2'}, {"What is a Ferrari", {"Car", "Animal", "Computer"}, '1'}, {"What is
Programming", {"Art", "....", "None of The Above"}, '1'}}' from '<brace-enclose
d initializer list>' to 'std::vector<Question>'
This is what I get when I try to test the code ?????????????
@Cbasic88: c++11 is almost like a whole new language. its the revised edition of c++ (i think 09). there is also one coming up called c++14. if you are using gcc or clang, you need compile like this: $(compiler) -std=c++11 (or c++0x) [other flags]. if youre using an ide then there is probably an option to let you do it