That is a poor method, it isn't completely random as count might not be equal to a random number we will be using the last word. What you want to do is load the words into an array and pick a random index from 1 to the number of words
Posted: Thu Apr 10, 2008 3:36 pm Post subject: Re: Data files
Saad @ Thu Apr 10, 2008 2:41 pm wrote:
What you want to do is load the words into an array and pick a random index from 1 to the number of words
Why store all the words into memory when they're already stored in the file? You're only going to be using one of the words per game.
In my opinion, BigBear's idea is decent, but his code... I understand what you were trying to do, but sit down and think through what you're program is going to do. Also two exit statements in one loop is poor structure. Spagetti code, huzzah!
Just a litte hint: Assign a random number to a variable outside the loop.