Hangman: case-sensitive problem?

Dylan Reinhold dylan at ocnetworking.com
Wed Jun 23 20:54:47 PDT 2010




The code makes all your answers lower case.

This patch will also compare the uppercase version of your letter.

diff --git a/games/hangman/getguess.c b/games/hangman/getguess.c
index b5b60c0..8a40c7c 100644
--- a/games/hangman/getguess.c
+++ b/games/hangman/getguess.c
@@ -71,8 +71,8 @@ getguess(void)
        Guessed[ch - 'a'] = TRUE;
        correct = FALSE;
        for (i = 0; Word[i] != '\0'; i++) {
-               if (Word[i] == ch) {
-                       Known[i] = ch;
+               if (Word[i] == ch || Word[i] == toupper(ch) ) {
+                       Known[i] = Word[i];
                        correct = TRUE;
                }
        }


Dylan

On 06/23/2010 02:33 PM, Tim Darby wrote:
<blockquote
 cite=""
 type="cite">While playing hangman, the
word offered was 'Theocritan', but when I guessed 't', it only filled
in the second 't'.  I haven't looked at the code, but I'm guessing that
it's not recognizing the uppercase T.
  
  
  Tim








More information about the Bugs mailing list