#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 lineRead[MAX_LINE_LEN] = {}; char *splitters = ",; \n"; int wordsRead = 0; while(fgets(lineRead,MAX_LINE_LEN,file) != NULL && wordsRead < maxWordCount){ char *token = strtok(lineRead, splitters); while(token != NULL && wordsRead < maxWordCount){ strcpy(words[wordsRead],token); //Kleinbuchstaben -> Grossbuchstaben int len = strlen(words[wordsRead]); for(int i = 0; i < len; i++){ //müsste einen kleinbustaben am ende haben if(islower(words[wordsRead][i])){ words[wordsRead][i] = toupper(words[wordsRead][i]); } } wordsRead++; token = strtok(NULL, splitters); } } return wordsRead; }