I need to make a hangman game but I have code but it won't end the game even if you ges the word, and it won't show the gesses all at once.
This is what I have
#include <iostream>
using namespace std;
int main()
{
char solution[20];
char blank[20];
int counter = 0;
int right = 0;
char guess;
cout<<"Enter phrase 20 chars or less."<<endl;
cin.getline(solution, 20);
int puzzLength = strlen(solution);
for (counter = 0; counter < puzzLength; counter++)
{
solution[counter] = toupper(solution[counter]);
}
for (counter = 0; counter < puzzLength; counter++) {
if (isalnum(solution[counter])) blank[counter] = '*';
else blank[counter] = solution[counter];
}
while (strcmp(solution, blank))
{
cout<<endl<<"Solution phrase is: "<<solution<<"."<<endl;
cout<<"The current 'blank' puzzle is: "<<blank<<"."<<endl;
cout<<"Enter a guess."<<endl;
cin>>guess;
guess = toupper(guess);
for (counter = 0; counter <= puzzLength; counter++)
{
if (guess == solution[counter])
{
blank[counter] = guess;
}
}
}
cout<<"Winner!";//Ican't get to this
cin.get();
return 0;
}