hey there...can anyone help to finish this:
my problem is:Code:#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> int A(); int B(); main () { char letters, errors, tries; int i, j; for(i=0;i<10;i++) { printf("\n"); for(j=0;j<4;j++) { printf("\t"); } } printf("*Welcome to HangMan*"); getch(); A(); getch(); return 0; } A() { int i, j; system("cls"); for(i=0;i<10;i++) { printf("\n"); for(j=0;j<4;j++) { printf("\t"); } } printf("*Welcome to HangMan*\n"); for(j=0;j<4;j++) { printf("\t"); } printf("*Press Enter to play*"); getch(); B(); } B() { char letter_guess; char letter[100]; char c, undscr; int x=0, i, j; int len; int loop; int total_tries=7; int tries; int count; int disk=0; system ("cls"); printf("enter the word to be guess: \n"); do{ c = getch(); switch(c) { case '\r': break; case '\b': printf("\b \b"); if(x>0) x--; break; default: letter[x++]= c; printf("%c", '*'); break; } }while(c != '\r'); letter[x]= '\0'; system("cls"); while(total_tries != 0) { printf("\n\ntries left: %d", total_tries); if(total_tries==7) { printf("\n\t\t_______\n\t\t| |\n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } else if(total_tries==6) { printf("\n\t\t_______\n\t\t| |\n\t\t| O \n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } else if(total_tries==5) { printf("\n\t\t_______\n\t\t| |\n\t\t| O \n\t\t| T\n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } else if(total_tries==4) { printf("\n\t\t_______\n\t\t| |\n\t\t| O \n\t\t| |T\n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } else if(total_tries==3) { printf("\n\t\t_______\n\t\t| |\n\t\t| O \n\t\t| |T|\n\t\t| \n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } else if(total_tries==2) { printf("\n\t\t_______\n\t\t| |\n\t\t| O \n\t\t| |T|\n\t\t| /\n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } else if(total_tries==1) { printf("\n\t\t_______\n\t\t| |\n\t\t| X \n\t\t| |T|\n\t\t| //\n\t\t| \n\t\t| \n\t\t| \n\t _|_\n\t /___|"); } printf("\n\n\nguessed letter: "); len=strlen(letter); undscr='_'; printf("\n\n"); printf("the word to guess is: "); for(loop=0;loop!=len;loop++) { printf(" %c", undscr); } printf("\nthe word to guess is: "); for(j=0; j!=len;j++){ printf(" %c", letter[j]); } printf("\n\nEnter a Letter(lowercase only): "); scanf("%c", letter_guess); getch(); return 0; }
1)changing the blanks into a letters;
2)when the inputted letter/s are wrong, the total_tries decrements and so the hangman;
3)when the letter get doubled it says that the letter is already input and the total_tries decrements;
4)when the total_tries reach "0" its game over, else if the word got completed print you win...
i'm using dev c++...thanks in advance...



2Likes
LinkBack URL
About LinkBacks




, i'll ask questions again if i got stuck...