#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. int leseEinWort(FILE *file, char zielWort[]) { int c; int i = 0; while((c = fgetc(file)) != EOF) // liest aus Textdatei und überprüft ob End Of File ist { if(isalpha(c) != 0) { if(i < MAX_WORD_LEN - 1) // -1 wegen '\0' { zielWort[i] = (char)toupper(c); // Für Großbuchstaben i++; } } else if(i > 0) { zielWort[i] = '\0'; return 1; } } if(i > 0) // Datei endet direkt nach ein WOrt ohne folgendes Leerzeichen oder so { zielWort[i] = '\0'; return 1; } return 0; } // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { int anzahl = 0; while((leseEinWort(file, words[anzahl])) == 1 && anzahl < maxWordCount) { anzahl++; } return anzahl; }