Is it possible to use rand() function on a txt file that i have used in a program??If so, how?
the file consists of a set of words out of which i want to select a random word every time the program is executed.
This is a discussion on rand() function on a file..!! within the Game Programming forums, part of the General Programming Boards category; Is it possible to use rand() function on a txt file that i have used in a program??If so, how? ...
Is it possible to use rand() function on a txt file that i have used in a program??If so, how?
the file consists of a set of words out of which i want to select a random word every time the program is executed.
Read the file into an array of words.
Pick a random subscript to get your random word.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.