Hangman
Hangman
h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void showHangman(int);
int main(void)
char hangmanWord[100], tempWord[100]; /**hangmanWord[] array for the original word and
tempWord[] array to get the alphabet from user and compare it with original word**/
char hangmanOutput[100]; /**This array will show the remaining blanks and correct
inputs**/
be set as 1**/
char alphabetFromUser;
cout<<"\n\n Now give the COMPUTER to your friend and see if he/she can CRACK it!!!";
cout<<"\n\n\tHIT >>ENTER<<";
getch();
getch();
clrscr();
cout<<endl<<"\n\n The word has %d alphabets \n\n"<<length; /**tell the user how many
alphabets the word has**/
hangmanOutput[i] = '_';
hangmanOutput[length] = '\0';
cout<<" ";
while(wrongTry != 0) /**while loop for exiting the program when no try left**/
matchFound = 0;
cout<<"\n\n enter any alphabet from a to z and please use small case!!";
if(alphabetFromUser < 'a' || alphabetFromUser > 'z') /**In case player gives input other than
'a' to 'z' the console will ask again**/
clrscr;
matchFound = 2;
// fflush(stdin);
if(matchFound != 2)
if(alphabetFromUser==hangmanWord[counter])
matchFound = 1;
}//end of if()
else
{
matchFound = 0;
if(alphabetFromUser == hangmanWord[counter])
position = counter ;
matchFound = 1;
}//end of if
if(matchFound == 1)
if( i == position)
continue;
else
tempWord[position] = alphabetFromUser; }
}//end of for
tempWord[length] = '\0'; /**put the NULL character at the end of the
temp string**/
if(winner == 0) /**if the player guessed the whole word right then
he/she is the WINNER**/
cout<<"\n\n\n\n\t\tEASY HUH???\n\n";
getch();
return 0;
cout<<"\n\n\t";
cout<<" ";
if(wrongTry <= 0) /**if the player can not guess the whole word in 5 chaces**/
return 0;