From 82ce9dddb2a8f8732ec5e274f85d5b48389c1a3d Mon Sep 17 00:00:00 2001 From: ChristineGoeppel Date: Mon, 26 Oct 2026 18:54:20 +0100 Subject: [PATCH 1/3] Implement word reading and uppercase conversion --- input.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/input.c b/input.c index ed77805..92064a2 100644 --- a/input.c +++ b/input.c @@ -8,5 +8,32 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + unsigned int wordCount=0;// die beiden Zähler also hier fertige wörter werden hier gespeichert + unsigned int letterCount=0;// zählt die gespeicherten zeichen der aktuellen wörter + int character; -} \ No newline at end of file + //ungültige parameter müssen abgefragt werden + if (file == NULL || words == NULL || maxWordCount == 0) { + return 0; + } + // datei zeichen für zeichen lesen + while (wordCount < maxWordCount && (character = fgetc(file)) != EOF) + { + //leerräume tc trennen die wörter + if (isspace(character) || character == ',' || character == ';') { + if (letterCount > 0) { + words[wordCount] [letterCount] = '\0'; + wordCount++; + letterCount=0; + } + } else if (letterCount < MAX_WORD_LEN -1 ) { + words[wordCount] [letterCount] = (char)toupper (character); + } + } + // letzes wort speicher, auch ohne trennzeichen am datei ende + if (letterCount > 0 && wordCount < maxWordCount) { + words[wordCount] [letterCount] = '\0'; + wordCount++; + } + return (int)wordCount; +} From dba181deb10924078458bc6618c5266854b2fee1 Mon Sep 17 00:00:00 2001 From: ChristineGoeppel Date: Thu, 29 Oct 2026 10:23:09 +0100 Subject: [PATCH 2/3] Implement word reading and uppercase conversion --- input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/input.c b/input.c index 92064a2..5fccc7c 100644 --- a/input.c +++ b/input.c @@ -16,7 +16,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) if (file == NULL || words == NULL || maxWordCount == 0) { return 0; } - // datei zeichen für zeichen lesen + // datei zeichen für zeichen lesen & fgetc (file get character) E0F (end of file) while (wordCount < maxWordCount && (character = fgetc(file)) != EOF) { //leerräume tc trennen die wörter @@ -27,7 +27,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) letterCount=0; } } else if (letterCount < MAX_WORD_LEN -1 ) { - words[wordCount] [letterCount] = (char)toupper (character); + words[wordCount] [letterCount] = (char)toupper (character);// to uppercase } } // letzes wort speicher, auch ohne trennzeichen am datei ende From 75984eb117493d43a5a9a5109fbb3daccba04c74 Mon Sep 17 00:00:00 2001 From: ChristineGoeppel Date: Thu, 29 Oct 2026 10:31:30 +0100 Subject: [PATCH 3/3] Implement word reading and uppercase conversion --- input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/input.c b/input.c index 5fccc7c..8f66115 100644 --- a/input.c +++ b/input.c @@ -28,6 +28,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) } } else if (letterCount < MAX_WORD_LEN -1 ) { words[wordCount] [letterCount] = (char)toupper (character);// to uppercase + letterCount++; } } // letzes wort speicher, auch ohne trennzeichen am datei ende