From f3180ad56e7d8ae0c15475343d1b1437612def66 Mon Sep 17 00:00:00 2001 From: fdlt3859 Date: Mon, 30 Jan 2023 17:39:38 +0000 Subject: [PATCH] Created loop func to make the word game easier --- src/main/quizproject.c | 13 +++++++++++++ src/main/quizproject.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index e086648..d4a0659 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -536,6 +536,18 @@ void play_guessingGame() { printf("****************************************\n"); } +void v_guessTheWord(char word[], char guessed[]) { + int i; + for (i = 0; i < strlen(word); i++) { + if (guessed[i]) { + printf("%c ", word[i]); + } else { + printf("_ "); + } + } + printf("\n"); +} + void play_guessTheWord() { char word[] = "Fulda"; char guessed[MAX_WORD_LENGTH] = {0}; @@ -549,6 +561,7 @@ void play_guessTheWord() { int correct = 0; printf("Lives: %d\n", lives); + v_guessTheWord(word, guessed); printf("Guess a letter: "); scanf(" %c", &guess); diff --git a/src/main/quizproject.h b/src/main/quizproject.h index 6850d0f..2497fc2 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -27,6 +27,7 @@ void feedbackForm(void); void displayCredits(void); void v_factorlie(void); void v_guessingGame(void); +void v_guessTheWord(char word[], char guessed[]); #define NUM_QUESTIONS 5 #define round 3