#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 puffer[MAX_WORD_LEN]; char *teiler = " ,;\n"; char *token; unsigned int wordCount = 0; fgets(puffer, MAX_LINE_LEN, file); token = strtok(puffer, teiler); while(token != NULL && wordCount < maxWordCount) { strncpy(words[wordCount], token, MAX_WORD_LEN -1); words[wordCount][MAX_WORD_LEN - 1] = '\0'; wordCount++; token =strtok(NULL, teiler); } return wordCount; }