#include "input.h" #include #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]; char* teiler = ".;, "; int wordCount = 0; char* token; while(fgets(zeile, MAX_LINE_LEN, file)!=NULL) { for (int i = 0; i < 1024; i++) { if (zeile[i] == '\n') { zeile[i] = '\0'; break; } } token = strtok(zeile,teiler); while(token != NULL && wordCount <= maxWordCount) { strcpy(words[wordCount],token); token = strtok(NULL,teiler); wordCount++; } } return wordCount; }