I need to make a handman game I have code but it won't show all the gesses at once and it won't end even if you get it right.
PLEASE HELP
This is what I have

#include <iostream>
using namespace std;

int main()
{
	char solution[20];	//holds solution
	char blank[20];		//holds "*"'s for unsolved letters
	int counter = 0;	//general-use counter
	int right = 0;		//1 = right guess, 0 = wrong guess.
	char guess;

	cout<<"Enter phrase 20 chars or less."<<endl;
	cin.getline(solution, 20);
	int puzzLength = strlen(solution);		//finds lengtrh of puzzle, stores INT value to puzzlength
	



		//convert puzzle to full uppercase
	for (counter = 0; counter < puzzLength; counter++){
		solution[counter] = toupper(solution[counter]);
	}
	//done converting
		
	

	
	for (counter = 0; counter < puzzLength; counter++) {		//converts characters to *'s to represent blanks

		if (isalnum(solution[counter])) blank[counter] = '*';
		else blank[counter] = solution[counter];
		
	}	//closes for loop

	while (strcmp(solution, blank))  //play game until the 'blank' puzzle becomes the 'right' answer
	{
		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);


		//cbeck guess!
		for (counter = 0; counter <= puzzLength; counter++) 
		{
				if (guess == solution[counter])  
				{
					blank[counter] = guess;		//fill in the puzzle with the letter
		
				}
	
		}		//close loop, done checking guess
	
	}	//game is over.

	cout<<"Winner!";
	cin.get();
	return 0;
}

PLEASE HELP

You stole the code directly from this thread :yawn:

I need to make a handman game

A handman? That's sounds a bit.. ehm.. :)

[edit]
On second thought:
To solve your problem, put this: strcpy_s(blank, solution); right after

for (counter = 0; counter < puzzLength; counter++)
{
solution[counter] = toupper(solution[counter]);
}

That way you all have the same (working) code and your teacher will fail you for sure ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.