473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to print random words in C?

hello.
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
1 2606
Frinavale
9,735 Expert Mod 8TB
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.

-Frinny
Dec 9 '10 #2

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

Similar topics

7
by: Hans A | last post by:
I have a textfile "textfile.txt" containing a list of words. There is one word on each line. I want to pick two random lines from this textfile, and I have tried to do something like: //Loading...
6
by: Andrew Chalk | last post by:
In a Python 2.2 app. running under CGI the statements print "Hello\n" print "World" print both words on the same line in IE6. How do I print the second one on a new line (i.e. respect the \n...
2
by: Code_Dark | last post by:
Hi, sorry to bore you with my newbie questions, but I _am_ a newbie so.. right. Anyway, I was working out a "number guessing game", which works fine, except I wanted to make the number a random...
4
by: theboringdays | last post by:
Im at the end of chapter 3 of "Python Programming For The Absolute Beginner, Michael Dawson " and he asks to make a fortune program that displays a fortune each time its ran, and to have 5 unique...
11
by: Olaf \El Blanco\ | last post by:
How can i generate random words? ('a'..'z') Is there any function that convert a number to it ascci char? My english is horrible! Here an example: function(65) return 'a'; Thank you!
7
by: Jay | last post by:
How would I be able to grab random words from an internet source. I'd like to grab a random word from a comprehensive internet dictionary. What would be the best source and the best way to go...
3
by: isaac86 | last post by:
how to print out d words that have length 7-10? printf ( "%u characters long for %s", strlen( data)-1,data ); wLength = strlen( data)-1; if(wLength == 7||8||9||10){ ...
1
by: qwertz | last post by:
Dear All; I Am New To Perl Not So Experienced::::i Would Like To Know How I Can Compare Two Different Hashes And Print Thecommon Values In Them::it Would Be Great If Simeone Could Help Me Thanks...
2
Thekid
by: Thekid | last post by:
I've been playing with the random module but can't seem to get my code to print out more than one random number. How do I go about that? I 've tried several things but haven't figured it out yet. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.