I'm just starting to use c++ and I've to make a hangman type game as a project. I have no idea what to do and need assistance thanks
It includes displaying a word from another file dictionary as asterisks then revealing the characters if the user guesses correctly. Any help would be appreciated
You will need to learn to get input from files with std::ifstream: http://www.cplusplus.com/reference/fstream/ifstream/
You will need std::strings, or char* arrays but they'll be harder and strings are recommended: http://www.cplusplus.com/reference/string/string/
You will have to get the work from the file and then place that in a string, then make another string that has the same amount of asterisks as the word. So something like this
1 2 3 4 5 6
std::ifstream words("input.txt");
string word;
words >> word;
string guessWord(word.size(), '*');
Thats a little help to get you started, if you need more help you need to post the code where you have given it a try
void openfile()
{
string getword;
ifstream inFile(“words8to10.txt”, ios::in);
if (!inFile.fail()) {
while (!inFile.eof()){
getline(inFile, getword);
cout << getword;
}
inFile.close();
}
else
cout << "File does not exist!";
}
i have to randomly select a word and output it as asterisks. I've got this so far:
void findword()
{
string dict[7926], secretword;
srand getword (time(NULL));
int randNumb = (rand() % 7926);
}