May 18, 2010 at 4:03pm May 18, 2010 at 4:03pm UTC
I make loads of riddle but I need to make it pick a random riddle from it.
how would I do do it?
Thank you in advance.
Last edited on May 18, 2010 at 4:04pm May 18, 2010 at 4:04pm UTC
May 18, 2010 at 4:04pm May 18, 2010 at 4:04pm UTC
What do you mean by random riddle?
What database is this, and how do you plan to access it?
Edit: 60 second response - not trolling, promise.
Last edited on May 18, 2010 at 4:05pm May 18, 2010 at 4:05pm UTC
May 18, 2010 at 4:06pm May 18, 2010 at 4:06pm UTC
When I said database basicly I put made loads of riddles in the script.
Sorry i'm finding it hard to get it out my head what I mean :(
May 18, 2010 at 4:41pm May 18, 2010 at 4:41pm UTC
Do you mean some kind of file with different 'riddles' on each line? And you want to choose a random line from that file (and thus a random riddle)?
May 18, 2010 at 7:28pm May 18, 2010 at 7:28pm UTC
Have a look at file IO: http://www.cplusplus.com/doc/tutorial/files/
and the srand function, for pseudorandom numbers.
Get the number of lines in the file, get a random number that is within that number of lines, and extract the given line based on the number using the filestream pointer.