#include "input.h" #include #include // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { int wordCount = 0; int charCount = 0; int c; while ((c = fgetc(file)) != EOF) { if (c == ',' || c == ';' || c == '\n' || c == '\r') { if (charCount > 0) { words[wordCount][charCount] = '\0'; wordCount++; charCount = 0; } if (wordCount >= maxWordCount) { break; } } else if (c == ' ' || c == '\t') { continue; // Leerzeichen und Tabs überspringen } else if (charCount < MAX_WORD_LEN - 1) { words[wordCount][charCount++] = (char)toupper((unsigned char)c); } } if (charCount > 0 && wordCount < maxWordCount) { words[wordCount][charCount] = '\0'; wordCount++; } fclose(file); return wordCount; }