I have just finished a hangman game in win console with words selected randomly from an array of strings. I need to change it get words randomly. I do not wish to get all the words and put them in an array. Instead I want to go to a specific line (text file has 1 word per line) and put the word in a string. Is this complicated? Any help would be appreciated a lot.
Could anyone write a small example pls? Say I need to get a word that is at line 3..
The links only seems to work with single characters. Is it the \n as a deliminator that has to do the magic?
Yes, if you want to write then use ofstream. But you cannot modify text file.
So, my recommendation is: read the entire file in array of strings, modify them as needed and save to file in any order you want.