From eb15c18771b8e9d9489ba7896a882a238d842076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Wed, 22 Oct 2025 18:11:46 +0200 Subject: [PATCH] ToDo 2D char Array --- Start_Windows/input.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Start_Windows/input.c b/Start_Windows/input.c index cacd6a4..8f4ea1d 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -13,6 +13,17 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) if (file == NULL) { printf("words,txt konnte nicht geoffnet werden"); } - // ToDo 2D char Array um wörter zu speichern kommt hier hin + // ToDo 2D char Array um wörter zu speichern kommt hier rein + char word[MAX_WORD_LEN]; + unsigned int count = 0; + while (fscanf(textdokument, "%s", word) != EOF && count < maxWordCount) { + // Kopiere das gelesene Wort in das 2D-Array + strncpy(words[count], word, MAX_WORD_LEN - 1); + words[count][MAX_WORD_LEN - 1] = '\0'; // Sicherstellen, dass der String nullterminiert ist + count++; + } + fclose(textdokument); + return count; + } \ No newline at end of file