#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) { // MAX_WORD_LEN 100 // MAX_LINE_LEN 1024 // *file ist Datei // words ist Array // MAX_WORD_LEN ist maximale Wortlänge // maxWordCount ist maximale Anzahl an Wörtern char puffer[MAX_LINE_LEN]; int counter = 0; while(fgets(puffer, MAX_LINE_LEN-1, file) != NULL && counter < maxWordCount) { char *parts = strtok(puffer, ",;/n/t. "); while(parts != NULL && counter < maxWordCount) { //strncpy(words[counter][MAX_WORD_LEN], puffer, MAX_LINE_LEN-1); //words[counter][MAX_WORD_LEN-1] = "\0"; //Großbuchstaben for(int i = 0; i < MAX_WORD_LEN -1 && parts[i] != '\0'; i++) words[counter][i] = toupper(parts[i]); } counter++; parts = strtok(NULL, ",;/n/t. "); } return counter; }