input richtig gestellt
This commit is contained in:
parent
0a87d89da3
commit
bd2e6f4e41
@ -32,28 +32,30 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
|
|
||||||
while (token != NULL && count < maxWordCount)
|
while (token != NULL && count < maxWordCount)
|
||||||
{
|
{
|
||||||
// Alles in Großbuchstaben umwandeln
|
// Überspringe leere Tokens
|
||||||
for (int i = 0; token[i]; i++)
|
if (token && strlen(token) > 0)
|
||||||
{
|
{
|
||||||
token[i] = toupper(token[i]);
|
// Alles in Großbuchstaben umwandeln
|
||||||
|
for (int i = 0; token[i]; i++)
|
||||||
// Prüfen, ob das Wort nur A-Z enthält
|
{
|
||||||
|
token[i] = toupper(token[i]);
|
||||||
|
}
|
||||||
|
// Prüfen, ob das Wort nur A-Z enthält
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!isValidWord(token))
|
if (!isValidWord(token))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Ungültiges Wort gefunden: '%s'. Nur Buchstaben A-Z erlaubt.\n", token);
|
fprintf(stderr, "Ungültiges Wort gefunden: '%s'. Nur Buchstaben A-Z erlaubt.\n", token);
|
||||||
token = strtok(NULL, delimiters);
|
token = strtok(NULL, delimiters);
|
||||||
continue; // Wort ignorieren
|
continue; // Wort ignorieren
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wort ins Array kopieren
|
||||||
|
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||||
|
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Wort ins Array kopieren
|
|
||||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
|
||||||
words[count][MAX_WORD_LEN - 1] = '\0';
|
|
||||||
count++;
|
|
||||||
|
|
||||||
token = strtok(NULL, delimiters);
|
token = strtok(NULL, delimiters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user