From 078e326e4d11a4381c1240c2646732f04968bf17 Mon Sep 17 00:00:00 2001 From: Bjoern Date: Tue, 28 Oct 2025 15:07:54 +0100 Subject: [PATCH] Umlautfunktion verbessert --- Start_Windows/input.c | 22 ++++++++++++++++++---- Start_Windows/input.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 2d49de6..b9fc7ec 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -19,19 +19,33 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) // Tokenize Zeile nach Trennzeichen char *token = strtok(line, delimiters); - while (token != NULL && count < maxWordCount) { + while (token != NULL && count < maxWordCount) + { // Alles in Großbuchstaben umwandeln - for (int i = 0; token[i]; i++) { + for (int i = 0; token[i]; i++) + { token[i] = toupper(token[i]); // 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); token = strtok(NULL, delimiters); continue; // Wort ignorieren } - */ } // Wort ins Array kopieren diff --git a/Start_Windows/input.h b/Start_Windows/input.h index 032ec28..a0c73dd 100644 --- a/Start_Windows/input.h +++ b/Start_Windows/input.h @@ -7,5 +7,6 @@ #define MAX_LINE_LEN 1024 int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount); +int isValidWord(const char *word) #endif