| | |
Selecting random word from file (C++)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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!
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!
![]() |
Similar Threads
- help! generate random word function from fiveLetter.txt file (Python)
- File I/O (Reading from a Random-Access File) NEW (C++)
- get a random word (C++)
Other Threads in the C++ Forum
- Previous Thread: How Do I Repeat The Programm Without Go Back To Windows?
- Next Thread: pointer to member?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets




