By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,600 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,600 IT Pros & Developers. It's quick & easy.

How to print random words in C?

P: 1
i want to print one of random words that i defined before, on screen. but using an external .txt or .dat file.
for example i add 100 words on the words.txt or words.dat file and program will print one of them randomly on screen.
Dec 8 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,731
Load the words into an array.

Calculate a random number between 0 and the length of the array.

Use that random number to retrieve a word from the array.

This will give you a random word.

Dec 9 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.