From 9d8a760f08f5733c2b8df2e17ed7fd3f42904c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Mon, 27 Oct 2025 13:24:06 +0100 Subject: [PATCH] =?UTF-8?q?input=20und=20anzeige=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Start_Windows/input.c | 12 +++++++----- Start_Windows/main.c | 4 +++- Start_Windows/words.txt | 6 +++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 3917fe2..ff247b8 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -14,23 +14,25 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) // Alle gewünschten Trennzeichen const char *delimiters = " \t\n,.;:!?\"'()[]{}"; - while (fgets(line, sizeof(line), file) && count < maxWordCount) { + // Zeile für Zeile lesen + while (fgets(line, sizeof(line), file) != NULL && count < maxWordCount) { + // Tokenize Zeile nach Trennzeichen char *token = strtok(line, delimiters); + while (token != NULL && count < maxWordCount) { // Alles in Großbuchstaben umwandeln for (int i = 0; token[i]; i++) { token[i] = toupper(token[i]); } + // Wort ins Array kopieren strncpy(words[count], token, MAX_WORD_LEN - 1); - words[count][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung + words[count][MAX_WORD_LEN - 1] = '\0'; count++; token = strtok(NULL, delimiters); } } - fclose(file); - return count; - + return count; // Datei nicht schließen – gehört dem Aufrufer } \ No newline at end of file diff --git a/Start_Windows/main.c b/Start_Windows/main.c index 043c42a..a44d97e 100644 --- a/Start_Windows/main.c +++ b/Start_Windows/main.c @@ -62,7 +62,9 @@ int main(int argc, char *argv[]) if(placedWords == wordCount) { // Start the game with the created word salad - startGame(wordSalad, SALAD_SIZE, words, wordCount, placedWords); + printf("Squares: %u, Words: %u\n", SALAD_SIZE, placedWords); + unsigned int windowWidth = 800; + startGame(wordSalad, SALAD_SIZE, words, wordCount, windowWidth); } else { diff --git a/Start_Windows/words.txt b/Start_Windows/words.txt index 30d74d2..31ee099 100644 --- a/Start_Windows/words.txt +++ b/Start_Windows/words.txt @@ -1 +1,5 @@ -test \ No newline at end of file +Yeti,Nessie Werwolf; Vampir +Monster +Hydra;Frankenstein +Dracula;KingKong;Gremlin;Kobold,Hexe;Poltergeist +Gespenst, Oger \ No newline at end of file