Umlautfunktion verbessert
This commit is contained in:
parent
491a85debd
commit
078e326e4d
@ -19,19 +19,33 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
// Tokenize Zeile nach Trennzeichen
|
// Tokenize Zeile nach Trennzeichen
|
||||||
char *token = strtok(line, delimiters);
|
char *token = strtok(line, delimiters);
|
||||||
|
|
||||||
while (token != NULL && count < maxWordCount) {
|
while (token != NULL && count < maxWordCount)
|
||||||
|
{
|
||||||
// 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
|
||||||
/*if (!isValidWord(token))
|
|
||||||
|
int isValidWord(const char *word)
|
||||||
|
{
|
||||||
|
for (int i = 0;word[i]; i++)
|
||||||
|
{
|
||||||
|
if (!('A' <= word[i] && word[i] <= 'Z'))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
// Wort ins Array kopieren
|
||||||
|
|||||||
@ -7,5 +7,6 @@
|
|||||||
#define MAX_LINE_LEN 1024
|
#define MAX_LINE_LEN 1024
|
||||||
|
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
|
||||||
|
int isValidWord(const char *word)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user