Hangman C source code

Italy
December 22, 2006 3:40am CST
Hangman game source code for you. ============ ----HANGMAN---- ============ Code: C char word[30],getit[30],*found; int score,loop,len,num,lup,om,luptimes,times,fitimes,o ndtimes,antimes; luptimes=0; fitimes=0; ondtimes=0; clrscr(); printf("\n ENTER THE WORD: "); gets(word); score=0; num=0; om=0; len=strlen(word); clrscr(); char gname[70]; printf("\n ENTER YOUR NAME: "); scanf("%s",gname); char h; printf("\n LET's START: "); h='_'; printf("\n LOOK HERE: "); for(loop=0;loop!=len;loop++) { printf("\n %c ",h); } for(loop=0;loop!=len;loop++) { om=1; num=num+1; fitimes=0; ondtimes=0; printf("\n\n %d LETTER",num); scanf("%s",&getit[num]); found=strchr(word,getit[num]); if(found) { for(luptimes=0;antimes=1;luptimes!=len;luptimes++, antimes++) { if(getit[num]==word[luptimes]) { fitimes++; } else { fitimes=fitimes; } } for(luptimes=num;luptimes!=0;luptimes--) { if(getit[num]==getit[luptimes]) { ondtimes++; } else { ondtimes=ondtimes; } } if(fitimes=ondtimes) { score=score+1; printf("\n OK\n"); for(lup=0;getit[num]!=word[lup];lup++) { om++; } printf("\n POSITION: %d\n",om); printf("\n ===================\n"); } else { score=score; printf("\n NOT AGAIN!\n"); } } else { score=score; printf("\n NO\n"); } } printf("\n THE WORD IS '%s'\n"word); printf("\n YOUR SCORE IS %d OUT OF %d",score,len); getch(); return 0; }
1 person likes this
8 responses
@dholey (1383)
• India
22 Dec 06
thanks for share, your code is having some errors , it has to be removed first, as it is for c (as you said, variables are to be declared just after the opening of the block, i.e just afer {,string.h must be included befor program, few variables are declared in c++ manner, in the printf () statement (just after the end of for loop "," is missing before word ) ) REST OF THE THINGS ARE SUPERB AND THANKS A LOT FOR THIS ALGORITHM , i have mentioned these thing just because if some neo programer wants to run this code he can correct it..... thanks again....
• Italy
22 Dec 06
Thank for your correction,I've just seen those. Sorry 4 that
@dholey (1383)
• India
24 Dec 06
it was really a nice share ... thanks for sharing algorithms .. hope you will share some more algorithms too...
• Italy
24 Dec 06
I will asap :)
@hobohobo (678)
• Indonesia
12 Jan 07
honestly i even not try it, but i hope i can try it soon because after i read the others response, it's seem great program, and the other reason i will try it soon because i like game, thanks for the source code
• Italy
13 Jan 07
You're welcome mate :)
@istanto (8548)
• Indonesia
24 Dec 06
do you have any good code direct x for vb ? Im still using DX7 and it's running very slow for surface image. Thanks
• Italy
24 Dec 06
I'm sorry but I was workin on it many month ago but then I quitted my project lol What do you need exactly?
@aquajoy (114)
• India
22 Dec 06
thanks this one of my favorite games and it is fun to play thanks for sharing
• Italy
22 Dec 06
I like it too, you're welcome
@paki143 (793)
• Pakistan
16 Jan 07
wow nice thanks to share it
@kaniam (582)
• India
25 Dec 06
good i will soon open a community on this after my 500 mark
@shyam4uall (1002)
• India
22 Dec 06
superb..thanks for sharing this code with all of us.But it would have been a great job if you have given it in its corrected form and with whole packed..means ready to use source ..so that like me a begineer can just execute it through any compiler and have the fun..
@harivinod (781)
• India
23 Dec 06
yes friend thanks for the code