From edc3b1f2df9143139d2c0db8cb04919cb76d7e16 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:53:27 +0100 Subject: [PATCH] Implementation der Funktion, dass bei passenden Buchstaben das displayWord erweitert wird. --- src/main/c/Tim/hangman.c | 27 ++++++++++++++++++++++++++- src/main/c/Tim/hangman.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 9af39d7..43949e9 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -51,7 +51,9 @@ void hangman() { printf("Bitte gib einen Buchstaben ein!\n"); scanf(" %c", &userSelection); - printf("%c\n", userSelection); + + letterGuessed(userSelection, guessWord, length, displayWord); + printf("%s\n", displayWord); } }while(userSelection != '0'); @@ -74,10 +76,33 @@ bool wordGuessed(char x[], char y[]) { if(strcmp(x,y) == 0) { + printf("Du hast gewonnen!\n"); return true; } else { return false; } +} + + +bool letterGuessed(char x, char y[], int length, char ptr[]) +{ + int counter = 0; + for(int i = 0; i0) + { + return true; + } + else + { + return false; + } + } \ No newline at end of file diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h index d3160df..9819b9a 100644 --- a/src/main/c/Tim/hangman.h +++ b/src/main/c/Tim/hangman.h @@ -5,5 +5,6 @@ void hangman(); char* getWordFromList(int); bool wordGuessed(char[],char[]); +bool letterGuessed(char, char[], int, char[]); #endif