im making something like jeopardy where you have qustions and such. But what i was wondering how can i do random qustions. and how should I go about making the qustions so they can be read. Dont do it for me, just some hints thats all... chow
im making something like jeopardy where you have qustions and such. But what i was wondering how can i do random qustions. and how should I go about making the qustions so they can be read. Dont do it for me, just some hints thats all... chow
Try assigning each question a variable, say, if you have 100 questions, number them 1-100... then do a random number between 1-100, return the value you get thru a function, whatever is returned display that question...
just a thought :d
I think this should be easy. I would use a 2D array with all the questions in it:
then use rand function to generate a random value and put it in the question array. . You can run it in a do, while loop. Oh, you should write a function that prevent the rand generates a number twice, since you have a do loop. Well it's all up to youCode:char question[number_questions][]={"question".....};
Hello, testing testing. Everthing is running perfectly...for now
I don't know much about the STL but I think a std::map might be a good choice.
i really dont know much about 2d arrays. but im sure inm y text book they mention it.. any more ideas or hints.
2D array is not that hard to understand. Ok, just imagine you need 3 char variables array. Normally, you'll do like this:Originally Posted by Gardul
Well, it's kinda long to declare like that, how about combine them into one. So we have:Code:char a1[]="first"; char a2[]="second"; char a3[]="third";
ta da!!! Now you have a 2D array character. Pretty simple heh.Code:char a[3][] = {"first", "second", "third"};
Hello, testing testing. Everthing is running perfectly...for now
Or if you are a C++ man. You can use strings which then you could just use a single array.
Woop?
I just read about that actually... I will have to give that a try. and yes I do use C++ Dev.. i was thinking maybe how boreland is soon.Originally Posted by hdragon
Oh well, yeah, forgot about string. String would be good for this kind of stuffOriginally Posted by prog-bman
Hello, testing testing. Everthing is running perfectly...for now
Originally Posted by hdragon
hmm qustion.. {"frist" } what do i put in the " "? would the qustion actually go in there? or just a number or something to link the qustion later?
Well, you can either use fstream to load the data into the array of characters or you just define it where you create the characters:
Put the question into the " " marks, like this:
So then when you want to call out the first question, you will use:Code:char a[3][] = {"This is question number 1", "This is question number 2", "this is question number 3"};
cout<<a[0];
same thing with the others
Hello, testing testing. Everthing is running perfectly...for now
good idea hdragon