input richtig gestellt
This commit is contained in:
parent
0a87d89da3
commit
bd2e6f4e41
@ -31,12 +31,15 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
char *token = strtok(line, delimiters);
|
char *token = strtok(line, delimiters);
|
||||||
|
|
||||||
while (token != NULL && count < maxWordCount)
|
while (token != NULL && count < maxWordCount)
|
||||||
|
{
|
||||||
|
// Überspringe leere Tokens
|
||||||
|
if (token && strlen(token) > 0)
|
||||||
{
|
{
|
||||||
// Alles in Großbuchstaben umwandeln
|
// Alles in Großbuchstaben umwandeln
|
||||||
for (int i = 0; token[i]; i++)
|
for (int i = 0; token[i]; i++)
|
||||||
{
|
{
|
||||||
token[i] = toupper(token[i]);
|
token[i] = toupper(token[i]);
|
||||||
|
}
|
||||||
// Prüfen, ob das Wort nur A-Z enthält
|
// Prüfen, ob das Wort nur A-Z enthält
|
||||||
|
|
||||||
|
|
||||||
@ -47,13 +50,12 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
token = strtok(NULL, delimiters);
|
token = strtok(NULL, delimiters);
|
||||||
continue; // Wort ignorieren
|
continue; // Wort ignorieren
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Wort ins Array kopieren
|
// Wort ins Array kopieren
|
||||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||||
words[count][MAX_WORD_LEN - 1] = '\0';
|
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
token = strtok(NULL, delimiters);
|
token = strtok(NULL, delimiters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user