Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board
Go4Expert
Go4Expert RSS Feed

Go Back   Programming and SEO Forum >  Go4Expert > Articles / Source Code > Game programming

Discuss / Comment  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More
 
Bookmarks Article Tools Search this Article Display Modes

Hangman game source code


On 9th August, 2006
Cool Hangman game source code

Show Printable Version Email this Page Subscription Add to Favorites Copy Hangman game source code link

Author

TEJUS ( Go4Expert Member )

Yet to provide details about himself


All articles By TEJUS

Recent Articles

Similar Articles

Hangman game source code for you.
============
----HANGMAN----
============
Code: C
#include<conio.h>
#include<string.h>
main()
{
    char word[30],getit[30],*found;
    int score,loop,len,num,lup,om,luptimes,times,fitimes,ondtimes,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;
}
Old 11-03-2006, 06:10 PM   #2
Go4Expert Member
 
TEJUS's Avatar
 
Join Date: Aug 2006
Location: IN KERALA,KOLLAM
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
TEJUS is on a distinguished road

Re: Hangman game source code


Why No One Is Replying ?
TEJUS is offline   Reply With Quote
Old 11-03-2006, 06:22 PM   #3
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,714
Thanks: 119
Thanked 293 Times in 227 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Hangman game source code


What you want in reply?
shabbir is offline   Reply With Quote
Old 11-25-2006, 10:53 AM   #4
Go4Expert Member
 
TEJUS's Avatar
 
Join Date: Aug 2006
Location: IN KERALA,KOLLAM
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
TEJUS is on a distinguished road

Re: Hangman game source code


i want to know wheter my program is good?
TEJUS is offline   Reply With Quote
Old 11-25-2006, 01:39 PM   #5
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,714
Thanks: 119
Thanked 293 Times in 227 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Hangman game source code


Quote:
Originally Posted by TEJUS
i want to know wheter my program is good?
Yup its a good one I must say.

Not more people are replying or commenting probably because of lack of some explanation / introductory para.
shabbir is offline   Reply With Quote
Old 12-01-2006, 10:21 PM   #6
Newbie Member
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
shailender0435 is on a distinguished road

Re: Hangman game source code


hey iam getting an error
undefined symbol_main in module c).ASM
shailender0435 is offline   Reply With Quote
Old 12-03-2006, 11:24 PM   #7
Go4Expert Member
 
rai_gandalf's Avatar
 
Join Date: Nov 2005
Location: Mumbai
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
rai_gandalf is on a distinguished road
Send a message via Yahoo to rai_gandalf
Question

9 Errors and 5 Warnings!! Whats this?!


Quote:
Originally Posted by shabbir
Yup its a good one I must say.

Not more people are replying or commenting probably because of lack of some explanation / introductory para.

How come u n Shabbir r sayin that its workin .... in my Borland Compiler its showing 9 Errors & 5 Warnings .... some of the errors dont even require a compiler - they r glaring sytax errors .... or mebbe I am wrong - mebbe I am using the wrong compiler .... pls do clarify and elaborate in this regard. Thx.

Ciao,
Rajiv
rai_gandalf is offline   Reply With Quote
Old 12-04-2006, 09:42 AM   #8
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,714
Thanks: 119
Thanked 293 Times in 227 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Hangman game source code


What I meant good is from code point of view and I never compiled it.

Yup it has some syntax errors and here is the rectification
Code:
#include<conio.h>
#include<string.h>
#include <stdio.h>

main()
{
    char word[30],getit[30],*found;
    int score,loop,len,num,lup,om,luptimes,fitimes,ondtimes,antimes;
    luptimes=0;
    fitimes=0;
    ondtimes=0;
    printf("\n ENTER THE WORD: ");
    gets(word);
    score=0;
    num=0;
    om=0;
    
    len=strlen(word);
    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;
}
shabbir is offline   Reply With Quote
Old 12-04-2006, 09:58 AM   #9
Go4Expert Member
 
rai_gandalf's Avatar
 
Join Date: Nov 2005
Location: Mumbai
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
rai_gandalf is on a distinguished road
Send a message via Yahoo to rai_gandalf
Question

3 Errors still remain!


There is still an error - the spacing between "ondtime" and "s". Rectify that and the code compiles without errors but with 4 warnings - all of "variable assigned a value but never used" .... But it does work in the way I think it should.

Ciao,
Rajiv
rai_gandalf is offline   Reply With Quote
Old 12-04-2006, 10:20 AM   #10
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,714
Thanks: 119
Thanked 293 Times in 227 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Hangman game source code


The space problem is actually the problem in the algo of parsing the code and not with the actual code.

If you have a line greater than n it will insert a space in between.

Normally that thing does not happen and in normal circumstances you dont have chars after chars without a space.
shabbir is offline   Reply With Quote
Discuss / Comment  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More


Currently Active Users Reading This Article: 1 (0 members and 1 guests)
 
Article Tools Search this Article
Search this Article:

Advanced Search
Display Modes
Bookmarks

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads / Articles
Thread Thread Starter Forum Replies Last Post
Some Multiple choice questions in C shabbir C-C++ 13 01-30-2008 10:00 AM
News:Build your own Visio 12 Like Flow/Diagram Application within C#(full source code jackonlyone C# 1 07-28-2006 08:20 PM
E-XD++ MFC Library Professional Edition V9.20 is released (100% Source Code)! jackonlyone MFC / Win32 0 04-12-2006 11:29 AM

 

All times are GMT +5.5. The time now is 05:14 AM.