#include "input.h" #include #include // TODO: // eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { char zeile[MAX_LINE_LEN]; int anzahlWord = 0; while (fgets(zeile, MAX_LINE_LEN, file)) { char *teiler = " .,;"; char *token = strtok(zeile, teiler); while (token != NULL && anzahlWord < maxWordCount) { strncpy(words[anzahlWord], token, MAX_WORD_LEN - 1); words[anzahlWord][MAX_WORD_LEN - 1] = '\0'; anzahlWord++; token = strtok(NULL, teiler); } } /*Alle Buchstaben zu Großbuchstaben umwandeln for (int i = 0; i < anzahlWord; i++) { int laenge = strlen(words[i]); for (int j = 0; j < laenge; j++) words[i][j] = toupper(words[i][j]); } */ return anzahlWord; }