Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Hanna ( 17 years ago )
I have some code provided to me that loads a dictionary of some words saved in a text file. The program I am trying to build is a hangman game that picks a random word from the text file that the user is unaware of. The user then starts guessing the letters. At every hot, the program will show you dashes for the non-guessed letter and placed the guessed letters where they belong. For example if the secret word loaded into the program from the text file is "bread" and the user guessed d, the program would outcome "----d" before asking for the next letter. If the user guessed wrong, the program will keep an increment of the number of misses and terminate "you lose" after 8 misses. I am stuck at how to make the random word generator that calls in a random word from a list of words in from a text file. I also understand that in order to do so, an array of strings will have to be created of all the words in the text file but how do you go about coding the actual generator? Maybe there are others way to do it I don't know but that is my guess....


Thanks!

 

Revise this Paste

Your Name: Code Language: