Question
This is for C Programming: For the folloiwng code, I get the follwing errors. Please assist with finding out why I am getting these errors.
This is for C Programming:
For the folloiwng code, I get the follwing errors. Please assist with finding out why I am getting these errors. Thank you so much.
ERRORS:
CODE:
#include
#include
#include
void showHangman(int);
int main(void)
{
char hangmanWord[100], tempWord[100];
char hangmanOutput[100];
int wrongTry = 6 , matchFound = 0;
int counter = 0 , position = 0, winner, length , i;
char alphabetFromUser;
system("cls");
printf(" Enter any word in small case and hit >>ENTER
printf(" \t Enter HERE ==> ");
scanf("%s",hangmanWord);
printf(" Now give the COMPUTER to your friend and see if he/she can CRACK it!!!");
printf(" \tHIT >>ENTER
getchar();
length = strlen(hangmanWord);
system("cls");
printf(" !!!!!!!!Welcome !!!!!! "); /**Brief description of the game**/
printf(" You will get 5 chances to guess the right word");
printf(" So help the Man and get...set...GO..!!");
getchar();
printf(" \tHIT >>ENTER
getchar();
system("cls");
printf(" \t||===== "); /**show the HANGMAN**/
printf(" \t|| | ");
printf(" \t|| ");
printf(" \t|| ");
printf(" \t|| ");
printf(" \t|| ");
printf(" The word has %d alphabets ",length); /**tell the user how many alphabets the word has**/
for( i = 0; i
{
hangmanOutput[i] = '_';
hangmanOutput[length] = '\0';
}
for(i = 0 ; i
{
printf(" ");
printf("%c",hangmanOutput[i]); /**Show the Word With n(length of the original word) number of underscores (_)**/
}
while(wrongTry != 0)
{
matchFound = 0;
printf(" enter any alphabet from a to z and please use small case!!");
printf(" \t Enter HERE ==> ");
fflush(stdin);
scanf("%c",&alphabetFromUser);
if(alphabetFromUser 'z') /**In case player gives input other than 'a' to 'z' the console will ask again**/
{
system("cls");
printf(" \t Wrong input TRY AGAIN ");
matchFound = 2;
}
fflush(stdin);
if (matchFound != 2)
{
for(counter=0;counter { if(alphabetFromUser==hangmanWord[counter]) { matchFound = 1; }//end of if() }//end of for() if(matchFound == 0) { printf(" \t :( You have %d tries left ",--wrongTry); getchar(); showHangman(wrongTry); getchar(); }//end of if() else { for(counter = 0; counter { matchFound = 0; if(alphabetFromUser == hangmanWord[counter]) { position = counter ; matchFound = 1; }//end of if if(matchFound == 1) { for(i = 0 ; i { if( i == position) { hangmanOutput[i] = alphabetFromUser; /**Put the alphabet at right position**/ } else if( hangmanOutput[i] >= 'a' && hangmanOutput[i] { continue; } else { hangmanOutput[i] = '_'; /** Put a blank at not guessed alphabet position **/ } } tempWord[position] = alphabetFromUser; /**put the alphabet in another char array to check with the original word**/ tempWord[length] = '\0'; /**put the NULL character at the end of the temp string**/ winner = strcmp(tempWord,hangmanWord); /**upon True comparison it will return 0**/ if(winner == 0) printf(" \t \t YAHOO!!!!! You are the WINNER !!!!!"); printf(" \t The Word was %s ",hangmanWord); printf(" \t\tEASY HUH??? "); getchar(); return 0; }//end of inner if }//end of outer if }//end of for loop }//end of else }// end of if(matchFound != 2) condition printf(" \t"); for(i = 0 ; i { printf(" "); printf("%c",hangmanOutput[i]); } getchar(); }//end of while loop if(wrongTry { printf(" \t The Word was %s ",hangmanWord); printf(" \t The man is dead you IDIOT!!!!!"); printf(" \t Better luck next!!!"); } getchar(); return 0; }//end of main(); void showHangman(int choice) /**This function show the hangman after each wrong try**/ { switch(choice) { case 0: system("cls"); printf(" \t||===== "); printf(" \t|| | "); printf(" \t|| %cO/",'\\'); printf(" \t|| | "); printf(" \t|| / %c",'\\'); printf(" \t|| "); break; case 1: system("cls"); printf(" \t||===== "); printf(" \t|| | "); printf(" \t|| %cO/",'\\'); printf(" \t|| | "); printf(" \t|| %c",'\\'); printf(" \t|| "); break; case 2: system("cls"); printf(" \t||===== "); printf(" \t|| | "); printf(" \t|| %cO/",'\\'); printf(" \t|| | "); printf(" \t|| "); printf(" \t|| "); break; case 3: system("cls"); printf(" \t||===== "); printf(" \t|| | "); printf(" \t|| %cO/",'\\'); printf(" \t|| "); printf(" \t|| "); printf(" \t|| "); break; case 4: system("cls"); printf(" \t||===== "); printf(" \t|| | "); printf(" \t|| %cO ",'\\'); printf(" \t|| "); printf(" \t|| "); printf(" \t|| "); break; case 5: system("cls"); printf(" \t||===== "); printf(" \t|| | "); printf(" \t|| O "); printf(" \t|| "); printf(" \t|| "); printf(" \t|| "); break; } return; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started