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