#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) { //kein fopen und close nötig, weil dies schon in der main passiert und mit *file übergeben wird// if (!file) { perror("Error invalid pointer to file"); return -1; } char line[1024]; unsigned int count = 0; while (fgets(line, sizeof(line), file) && count < maxWordCount) { line[strcspn(line, "\n")] = '\0'; char *token = strtok(line, " ;,"); while (token && count < maxWordCount) { strcpy(words[count], token); count++; token = strtok(NULL, " ;,"); } } return count; }