#include "input.h" #include #include // Trennzeichen, die in words.txt zwischen den Wörtern vorkommen static int isDelimiter(int c) { return c == ',' || c == ';' || isspace((unsigned char)c); } // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { if (file == NULL || words == NULL) { return 0; } unsigned int count = 0; unsigned int len = 0; int c; while (count < maxWordCount && (c = fgetc(file)) != EOF) { if (isDelimiter(c)) { if (len > 0) { words[count][len] = '\0'; count++; len = 0; } } else if (len < MAX_WORD_LEN - 1) { words[count][len++] = (char)toupper((unsigned char)c); } } if (len > 0 && count < maxWordCount) { words[count][len] = '\0'; count++; } return (int)count; }