#include "input.h" #include #include #define MAX_WORD_LEN 100 // 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 anzahlWoerter = 0; char zeile[500]; int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { while(anzahlWoerter <= maxWordCount && fgets(zeile, sizeof(zeile), file)){ char *wort[] = strtok(zeile, ",; \n"); while(wort != NULL && anzahlWoerter <= maxWordCount){ strncpy(words[anzahlWoerter], wort, anzahlWoerter -1); words[anzahlWoerter][MAX_WORD_LEN - 1]= '\0'; anzahlWoerter++; *wort = strtok(NULL, ",; \n"); } } return anzahlWoerter; }