From ae1adadfeeed3f3b20f6da5b619713164af380f1 Mon Sep 17 00:00:00 2001 From: Jonas Hruschka Date: Wed, 28 Oct 2026 14:55:45 +0100 Subject: [PATCH 1/2] Implement readWords --- Startcode/input.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/Startcode/input.c b/Startcode/input.c index ed77805..a87fa3e 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -5,8 +5,41 @@ // TODO: // eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. -// Read words from file and store in 'words' array -int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) -{ +// Read words from file and store in 'words' -} \ No newline at end of file + +int readWords(FILE *file, char words[][MAX_WORD_LEN], + unsigned int maxWordCount) +{ + if (file == NULL) { + return 0; + } + + char line[MAX_LINE_LEN]; + unsigned int wordCount = 0; + + while (wordCount < maxWordCount && + fgets(line, sizeof(line), file) != NULL) { + + char *word = strtok(line, " ,;\n\t\r"); + + while (word != NULL && wordCount < maxWordCount) { + strncpy(words[wordCount], word, MAX_WORD_LEN - 1); + words[wordCount][MAX_WORD_LEN - 1] = '\0'; + + unsigned int i = 0; + + while (words[wordCount][i] != '\0') { + words[wordCount][i] = + (char)toupper((unsigned char)words[wordCount][i]); + i++; + } + + wordCount++; + + word = strtok(NULL, " ,;\n\t\r"); + } + } + + return (int)wordCount; +} From 54d2b81fae81be4608d9d0c621d6b131b95a37bd Mon Sep 17 00:00:00 2001 From: Jonas Hruschka Date: Wed, 28 Oct 2026 14:59:47 +0100 Subject: [PATCH 2/2] Delete Hallo Maxi --- Startcode/graphicalGame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Startcode/graphicalGame.c b/Startcode/graphicalGame.c index 45daf8e..065a3ed 100644 --- a/Startcode/graphicalGame.c +++ b/Startcode/graphicalGame.c @@ -7,7 +7,7 @@ #define MAX_MESSAGE_LEN 256 #define MAX_SOLUTION_WORD_LEN 16 -//hallo maxi + typedef struct {