From 1a7ddaa7cd3dc8aade69975c46f7cca1cbe811d5 Mon Sep 17 00:00:00 2001 From: Sebastian Korinek Date: Fri, 31 Oct 2025 09:30:35 +0100 Subject: [PATCH 1/3] Update Makefile --- Start_Mac/makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Start_Mac/makefile b/Start_Mac/makefile index 1d3b4a6..2c67bdd 100644 --- a/Start_Mac/makefile +++ b/Start_Mac/makefile @@ -19,6 +19,9 @@ wordsalad_initial: wordsalad: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS) +wordsalad_myversion: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a + $(CC) $(CFLAGS) -o wordsalad_myversion main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS) + main.o: main.c $(CC) -c $(CFLAGS) main.c From 128a7f60a7fad7c2ebedd6b1ab0546f3fdaa759c Mon Sep 17 00:00:00 2001 From: Sebastian Korinek Date: Fri, 31 Oct 2025 09:35:33 +0100 Subject: [PATCH 2/3] INPUT Update (denke fertig) --- Start_Mac/input.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Start_Mac/input.c b/Start_Mac/input.c index ed77805..1d8cdfc 100644 --- a/Start_Mac/input.c +++ b/Start_Mac/input.c @@ -8,5 +8,33 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + unsigned int count = 0; + char buffer[256]; // temporärer Speicher für Zeilen + // Solange Zeilen vorhanden sind + while (fgets(buffer, sizeof(buffer), file) != NULL) + { + char *token = strtok(buffer, " \t\r\n.,;:!?()[]{}\"'"); // Trennzeichen + + while (token != NULL) + { + // Sicherheitscheck: Nicht über maxWordCount hinausgehen + if (count >= maxWordCount) + return count; + + // Nur gültige Wörter übernehmen + // (z. B. alles in Kleinbuchstaben) + for (int i = 0; token[i]; i++) + token[i] = tolower((unsigned char)token[i]); + + // In words[count] kopieren + strncpy(words[count], token, MAX_WORD_LEN - 1); + words[count][MAX_WORD_LEN - 1] = '\0'; // String terminieren + count++; + + token = strtok(NULL, " \t\r\n.,;:!?()[]{}\"'"); + } + } + + return count; } \ No newline at end of file From 4b028daa2ded314d7e144b8bcac8e3f8d7e2bd2e Mon Sep 17 00:00:00 2001 From: Sebastian Korinek Date: Fri, 31 Oct 2025 11:04:33 +0100 Subject: [PATCH 3/3] INPUT komplett fertig, nur noch 3 Fehler beim Test, Rest muss in game.c gaendert werden --- Start_Mac/input.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Start_Mac/input.c b/Start_Mac/input.c index 1d8cdfc..73c70cd 100644 --- a/Start_Mac/input.c +++ b/Start_Mac/input.c @@ -1,7 +1,7 @@ #include "input.h" #include #include - +#include //sicherstellen, dass FILE deklariert ist // TODO: // eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. @@ -11,23 +11,22 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) unsigned int count = 0; char buffer[256]; // temporärer Speicher für Zeilen - // Solange Zeilen vorhanden sind - while (fgets(buffer, sizeof(buffer), file) != NULL) + // zusätzliche Bedingung "count < maxWordCount" + while (count < maxWordCount && fgets(buffer, sizeof(buffer), file) != NULL) { + // gleiche Trennzeichen, aber Formatierung beibehalten char *token = strtok(buffer, " \t\r\n.,;:!?()[]{}\"'"); // Trennzeichen while (token != NULL) { - // Sicherheitscheck: Nicht über maxWordCount hinausgehen if (count >= maxWordCount) - return count; + break; // Sicherheitsabbruch auch hier - // Nur gültige Wörter übernehmen - // (z. B. alles in Kleinbuchstaben) + // toupper(), um Großbuchstaben zu erzwingen for (int i = 0; token[i]; i++) - token[i] = tolower((unsigned char)token[i]); + token[i] = toupper((unsigned char)token[i]); - // In words[count] kopieren + // sicheres Kopieren ins Zielarray strncpy(words[count], token, MAX_WORD_LEN - 1); words[count][MAX_WORD_LEN - 1] = '\0'; // String terminieren count++;