Selecting random word from file (C++)

Please support our C++ advertiser: Intel Parallel Studio Home
Closed Thread

Join Date: Aug 2004
Posts: 19
Reputation: Pikachu is an unknown quantity at this point 
Solved Threads: 0
Pikachu's Avatar
Pikachu Pikachu is offline Offline
Newbie Poster

Selecting random word from file (C++)

 
0
  #1
Aug 12th, 2004
I've created a file called country.txt which holds a list of 100 countries' name. Eg (to name a few):

America
Bahamas
Canada
Denmark
Eygpt
France
Germany
Hong Kong

My question is, how would I have the computer pick a random country name from the list above? Do I have to put a number at the front like below and use the random number generator? (if yes, can someone guide me on how to write in out in C++ format?)

1America
2Bahamas
3Canada
4Denmark
5Eygpt
6France
7Germany
8Hong Kong


Thank you!
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC