Thread: Hangman game

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    102

    Hangman game

    Hi I am trying to write a hangman game. This is where I am stuck. Will just paste part of the code that is relevant:

    Code:
    for(int i = 0; word[i]!=0; i++) {                          
                 
                if(word[i] != character) word[i] = '-';
    This code does what I want it to do - to an extent. So if I type in the word hangman, and the guess word is h, I will get h----- Which is fine. Now my problem is this. Next time, if someone types in n, I want the code to print out h-n---n and not just --n---n And this is where I am stuck. When I am dealing with one single character, it is fine. But when dealing with more than one character, I don't know how to do it. And I am not supposed to use the string class.

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    102
    Thanks, managed to figure out on my own. Sorted out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with hangman game.
    By astarialexi in forum C Programming
    Replies: 8
    Last Post: 03-13-2011, 04:04 AM
  2. !Help! Similar to hangman game
    By xxdevillxx in forum C Programming
    Replies: 2
    Last Post: 03-02-2011, 07:14 PM
  3. suggestion game hangman
    By blob84 in forum C Programming
    Replies: 1
    Last Post: 08-04-2010, 08:11 AM
  4. Hangman Game - Need Help!!
    By krobort in forum C++ Programming
    Replies: 3
    Last Post: 10-12-2006, 04:15 PM
  5. New game: Hangman!
    By abrege in forum Game Programming
    Replies: 6
    Last Post: 12-05-2002, 02:05 PM