Changed Input.c to solve Test 2 & 3 Aswell
This commit is contained in:
parent
713355b1ac
commit
000bc1ebdf
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user