Changed Input.c to solve Test 2 & 3 Aswell

This commit is contained in:
Jonas Stamm 2025-10-24 22:09:30 +02:00
parent 713355b1ac
commit 000bc1ebdf
2 changed files with 6 additions and 14 deletions

View File

@ -6,20 +6,16 @@
// TODO:
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
unsigned int count = 0;
// Solange noch Platz ist und Wörter vorhanden sind
while (count < maxWordCount && fscanf(file, "%s", words[count]) == 1) {
// Optional: alle Buchstaben in Kleinbuchstaben umwandeln
for (int i = 0; words[count][i]; i++) {
words[count][i] = tolower((unsigned char)words[count][i]);
words[count][i] = toupper((unsigned char)words[count][i]);
}
count++;
}
return count; // gibt zurück, wie viele Wörter tatsächlich eingelesen wurden
}
return count;
}

View File

@ -6,20 +6,16 @@
// TODO:
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
unsigned int count = 0;
// Solange noch Platz ist und Wörter vorhanden sind
while (count < maxWordCount && fscanf(file, "%s", words[count]) == 1) {
// Optional: alle Buchstaben in Kleinbuchstaben umwandeln
for (int i = 0; words[count][i]; i++) {
words[count][i] = tolower((unsigned char)words[count][i]);
words[count][i] = toupper((unsigned char)words[count][i]);
}
count++;
}
return count; // gibt zurück, wie viele Wörter tatsächlich eingelesen wurden
}
return count;
}