This commit is contained in:
dunkellu103850 committed 2026-10-28 09:13:17 +01:00
1 parent 7d518049a1
commit 3ab8b26e05
1 file changed
+36 -1
+36 -1
View File
@@ -8,5 +8,40 @@
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
int c = 0;
int count = 0;
int letterCount = 0;
while (count < maxWordCount)
{
while ((c = fgetc(file)) != EOF) //Leerzeichen prüfen
{
if (isspace(c) || !isalpha(c)) {
if (letterCount > 0) {
break; //Wort fertig eingelesen
}
continue; // mehrere Leerzeichen oder Sonderzeichen überspringen
}
if (letterCount < MAX_WORD_LEN - 1) //wörter Buchstabenweise einlesen
{
words[count][letterCount] = (char)toupper(c);
letterCount++;
}
}
if (letterCount == 0) {
break; //kein weiteres Wort gefunden
}
words[count][letterCount] = '\0';
letterCount = 0;
count++;
if (c == EOF) {
break;
}
}
return count;
}
}dhckhdkfhdjf