From b97858be05409df3c6e064206652d402c76c5c95 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 19:44:33 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Auslagern=20von=20Funktionalit?= =?UTF-8?q?=C3=A4t=20um=20einen=20return-Wert=20f=C3=BCr=20Test=20zu=20erh?= =?UTF-8?q?alten=20+=20Separieren=20der=20Variablendeklaration=20von=20gue?= =?UTF-8?q?ssWord=20und=20displayWord=20f=C3=BCr=20erh=C3=B6hte=20=C3=9Cbe?= =?UTF-8?q?rsichtlichkeit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 0e63451..974f5b6 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -6,6 +6,8 @@ #define LISTSIZE 10 #define MAX_WORD_LENGTH 30 +char* getWordFromList(int); +int getParameters(int, char*); char wordlist[LISTSIZE][MAX_WORD_LENGTH] = { "Kartoffel", "Zigarette", "Haus", "Fenster", "Kartenleseettiketiergeraet", @@ -26,11 +28,12 @@ void hangman() do { char guessWord[MAX_WORD_LENGTH]; - char displayWord[MAX_WORD_LENGTH]; int length; - strcpy(guessWord,wordlist[rand() % LISTSIZE]); + strcpy(guessWord,getWordFromList(rand() % LISTSIZE)); length = strlen(guessWord); printf("%s %d\n",guessWord, length); + + char displayWord[MAX_WORD_LENGTH]; for (int i = 0; i <= length; i++) { if(i