Thread: Need a little help with hangman

  1. #31
    Registered User
    Join Date
    Apr 2007
    Posts
    15
    OMG OMG Thank you all for ya'll help. One more question real fast! It's working, by the way, but it's not printing the first printf's in the loop.

    Code:
    int main()
    {
         int i;
         char c;
         FILE *in_file;
         
         in_file = fopen("wordlist.txt","r");
         
         do {
            if( feof(in_file) )
                rewind(in_file);
                
            fscanf(in_file, "%s", word_to_guess);
            
            for(i = 0; i < strlen(word_to_guess); i++) {
                  word_to_guess[i] = tolower(word_to_guess[i]);
            }
            
            initialize();
            instruct();
            do {
               printf("/n Number of tries left : %d", guess);
               printf("/n %s", letters_guessed);
               printf("/n Word to guess : ");
               
               for(i = 0; i<strlen(word_in_prog); i++)
                   printf("%c ", word_in_prog[i]);
                   
               printf("Please guess a letter : ");
                          gets(&c);
               c = tolower(c);
               if( !letter_check(c) )
                  guess--;
                  
            } while( guess > 0 && !won() );
            if( guess == 0 ) 
                printf("\n You LOSE!");
         } while(play_again());
         
         fclose(in_file);
    }
    Any reason ya'll can think of?

  2. #32
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    append newline character to end of your printf string. this character is '\n' not '/n'

  3. #33
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

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. Help doing Hangman...
    By Kreative in forum C Programming
    Replies: 11
    Last Post: 08-18-2002, 09:22 PM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM