Help doing Hangman...

This is a discussion on Help doing Hangman... within the C Programming forums, part of the General Programming Boards category; I need help doing a very very simple hangman program... Im very new to C, and im trying to do ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    3

    Unhappy Help doing Hangman...

    I need help doing a very very simple hangman program...
    Im very new to C, and im trying to do a hangman program, using stdlib, stdio and conio... and maybe string, but if you can without string it would be better... its supposed that i only have to use for and if, but if i cant it wouldnt matter... i just need a simple hangman program that have the following:
    1 - abc
    2 - random name
    3 - the _ _ _ _ of the word
    4 - that wen you introduce the letter, the letter on the abc will change(like the color)
    5 - and, of course, the little man, the hangman boy...

    this is what i have so far....
    --------------------------------------------------------
    #include<stdio.h>
    #include<stdlib.h>
    #include<conio.h>
    #include<string.h>
    #include<ctype.h>

    char words[3][10]={"HEY","WHAT THE...","WWW.YAHOO.COM"};
    char word[10], res[10];
    char letter,opc,catego;

    int i,j,y,elect,long,opor,a;


    void main(void){

    do{

    i=j=y=elec=long=opor=a=0;
    clrscr();
    for(i=0;i<10;i++)
    {
    res[i]=NULL;
    }

    gotoxy(32,1);
    printf("Hangman Game");

    /*abc*/
    for(i=0;i<26;i++)
    {
    gotoxy(i*2+18,4);
    printf("%c",65+i);
    }

    randomize();
    j = random(9);
    long=strlen(word);

    for (i=1;i<=long;i++){
    gotoxy(15+i*4+14,20); printf("_");
    }



    do{
    gotoxy(25,9);
    printf("Write Word:");
    do{
    letter=toupper(getch());
    }while(!isalpha(letter));

    gotoxy(10+opor*3,22);
    printf("%c",letter);

    for(i=0;i<long;i++)
    {
    if(letter==word[i])
    {
    gotoxy(15+i*4+18,19);
    printf("%c",letter);
    res[i]=letter;
    }
    }
    y=strcmp(word,res);

    if(y==0){
    gotoxy(32,33);
    printf("YEAH!");
    opor++;}
    }while(opor<30 && y!=0);

    if (opor==20)
    {
    gotoxy(26,30);
    textcolor(3);
    cprintf("WRONG: %s",word);
    }
    gotoxy(28,25);
    printf("Play Again?");
    do{
    opc=toupper(getch());
    }while(opc!='Y' && opc!='N');
    }while(opc!='N');
    }
    ---------------------------
    please i really need help with this....

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    What specifically do you need help with? Is there something that doesn't work, or a section you haven't finished? The first suggestion is to always use int (main), it's just better that way, and void main() isn't really accepted by programmers.

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Code:
    And please, use code tags.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    char words[3][10]={"HEY","WHAT THE...","WWW.YAHOO.COM"};
    char word[10], res[10];
    char letter,opc,catego;

    int i,j,y,elect,long,opor,a;
    Yuck. All globals? This is very poor design.

    void main(void){
    Now this is just plain wrong. The 'main' function ALWAYS returns an integer in C. If you want a main function that returns void, use Java.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Kreative
    Guest

    sorry

    I know i donw know much about C, im very new at this... but i need this hangman program in a very very very simple way... if someone can help me out...

  6. #6
    Unregistered
    Guest

    prof want it that way

    our prof want the hangman program using

    char word[10][30]={"....","..."...};
    char words;

    int i,x,y;

    etc....

    i really need help with this...

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Start by thinking about how your program will work, and what flow it will take. Then write this down in pseudo code, and once you think you've got it, start converting the pseudo to real code.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User
    Join Date
    Aug 2002
    Posts
    3
    can someone send me the hangman program, a very very simple hangman program... please?
    it should read the chars using a bidimencional array (char[10][30])... it should show the abc, and change the color of the abc when you press the letter... and it should have the hangman boy, please i need it for a grade, if someone can help me out... i can only use stdio.h, conio.h, stdlib.h and string.h... but it would be better if you can do it without string.h... thanks!

  9. #9
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Sorry, we don't do your homework here. Just take your time and keep working at it. If you have specific questions, then feel free to come back and ask them. No one here is going to write one for you.
    EntropySink. You know you have to click it.

  10. #10
    Registered User
    Join Date
    Aug 2002
    Posts
    3

    oh sorry...

    im trying hard, but its hard... i dont know much about C, almost nothing about C... well, anyway, sorry for asking that... i know its not right... thanks anyway

  11. #11
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    you can still ask pointed questions... like if you're having problems with a loop, or don't know how to make something happen... just don't expect us to write the whole thing for you.
    EntropySink. You know you have to click it.

  12. #12
    Unregistered
    Guest
    k, thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hangman Help - Code included
    By darren78 in forum C Programming
    Replies: 3
    Last Post: 02-17-2009, 09:35 AM
  2. Hangman Game Troubles
    By emerica240 in forum C Programming
    Replies: 9
    Last Post: 11-26-2008, 01:39 AM
  3. Hangman, Help me with the thinking
    By Livijn in forum C# Programming
    Replies: 14
    Last Post: 02-09-2008, 03:16 PM
  4. Hangman Game - Part 2
    By tigrfire in forum C Programming
    Replies: 1
    Last Post: 11-28-2005, 03:20 AM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21