Hey
I'm doing a hangman project at the moment,I have a string array containing 10 words to be guessed.I can generate a random number between 0 and 9 but how do i compare this to the index of the elements to randomly pick a word???
thanks
Hey
I'm doing a hangman project at the moment,I have a string array containing 10 words to be guessed.I can generate a random number between 0 and 9 but how do i compare this to the index of the elements to randomly pick a word???
thanks
Since you can pick a random number in the right range, just use THAT as the index into the array.
Mainframe assembler programmer by trade. C coder when I can.
I am not sure what is the question. Don't you already have a random index that you can immediately use?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Ok,i have an array with 10 words and i want to pick one of them randomly,how do i do it
You would "generate a random number between 0 and 9" and then use that number as the index of the randomly chosen element.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)