#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) { unsigned int wordCount = 0; char line[MAX_LINE_LEN]; // Read file line by line while (fgets(line, MAX_LINE_LEN, file) != NULL && wordCount < maxWordCount) { // Process each line to extract words separated by delimiters char *token = strtok(line, " ,;\n\t\r"); while (token != NULL && wordCount < maxWordCount) { // Convert word to uppercase and store it unsigned int i = 0; while (token[i] != '\0' && i < MAX_WORD_LEN - 1) { words[wordCount][i] = toupper((unsigned char)token[i]); i++; } words[wordCount][i] = '\0'; // Only count non-empty words if (i > 0) { wordCount++; } token = strtok(NULL, " ,;\n\t\r"); } } return wordCount; }