diff --git a/Start_Windows/input.c b/Start_Windows/input.c index ed77805..76a84ac 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -8,5 +8,32 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + if (file == NULL) + return 0; + unsigned int count = 0; + char line[512]; + + // Lese Datei zeilenweise + while (fgets(line, sizeof(line), file) != NULL && count < maxWordCount) + { + // Zerlege die Zeile in Tokens (Wörter), getrennt durch gängige Delimiter + char *token = strtok(line, " ,;:.!?\"\n\r\t"); + + while (token != NULL && count < maxWordCount) + { + // In Großbuchstaben umwandeln + for (int i = 0; token[i]; i++) + token[i] = toupper((unsigned char)token[i]); + + // Wort kopieren + strncpy(words[count], token, MAX_WORD_LEN - 1); + words[count][MAX_WORD_LEN - 1] = '\0'; + + count++; + token = strtok(NULL, " ,;:.!?\"\n\r\t"); + } + } + + return count; } \ No newline at end of file