#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. // Wörter werden durh ",", ", " oder ";" getrennt // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { int word_count = 0; char *teiler = " ;,\n"; char buffer[MAX_WORD_LEN * maxWordCount]; char *token; while(fgets(buffer, MAX_WORD_LEN * maxWordCount, file) != NULL){ token = strtok(buffer, teiler); while(token != NULL){ strncpy(words[word_count], token, MAX_WORD_LEN); char *s = words[word_count]; while (*s != '\0') { *s = toupper((unsigned char) *s); s++; } word_count++; token = strtok(NULL, teiler); } } return word_count; }