954,136 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Selecting random word from file (C++)

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!

Pikachu
Newbie Poster
19 posts since Aug 2004
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You