This commit is contained in:
hentschdu103698 committed 2026-11-02 14:02:33 +01:00
1 parent eb37f451d0
commit 6259f06391
9 files changed
+109 -1

No files matched your search

+13
View File
@@ -8,5 +8,18 @@
// 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 buffer[MAX_WORD_LEN];
while (wordCount < maxWordCount && fscanf(file, "%s", buffer) == 1) {
for (int i = 0; buffer[i]; i++) {
buffer[i] = tolower(buffer[i]);
}
strncpy(words[wordCount], buffer, MAX_WORD_LEN - 1);
words[wordCount][MAX_WORD_LEN - 1] = '\0';
wordCount++;
}
return wordCount;
}