#include "input.h" #include #include #define DELIMITERS " ,;\t\r\n" // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { char puffer[MAX_LINE_LEN]; unsigned int wordCount = 0; if(file == NULL || words == NULL) return 0; //Liest die Datei Line by Line while(wordCount < maxWordCount && fgets(puffer, MAX_LINE_LEN, file) != NULL) { //Trennt das erste Wort der Zeichenkette, abhängig von den Teilerbedingungen char *token = strtok(puffer, DELIMITERS); //geht über das token und speichert sie einzeln in Uppercase while(token != NULL && wordCount < maxWordCount) { unsigned int i = 0; while(token[i] != '\0' && i < MAX_WORD_LEN -1) { words[wordCount][i] = (char)toupper((unsigned char)token[i]); i++; } words[wordCount][i] = '\0'; wordCount++; token = strtok(NULL, DELIMITERS); } } return wordCount; }