From 74c3415bae6812266e4a976e72bf900f82cfa296 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Fri, 23 Oct 2026 10:27:11 +0200 Subject: [PATCH 1/6] created basic functionality --- Startcode/input.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Startcode/input.c b/Startcode/input.c index ed77805..747448f 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -1,12 +1,55 @@ #include "input.h" #include #include +#include // TODO: // eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. // Read words from file and store in 'words' array +static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN], unsigned int maxWordCount); + int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + int wordCount = 0; + int i = 0; + char lineRead[MAX_LINE_LEN]; + while(fgets(lineRead, MAX_LINE_LEN, file) != NULL && i < maxWordCount) + { + wordCount += createSingleWords(lineRead, words, maxWordCount); + i++; + } + + return wordCount; +} + +static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN], unsigned int maxWordCount) +{ + char *teiler = " ;,.\n"; + char *token; + + int i = 0; + + token = strtok(text, teiler); + + while(token != NULL && i < maxWordCount) + { + strncpy(words[i], token, MAX_WORD_LEN - 1); + //kleinbuchstaben --> GROßBUCHSTABEN + int length = strlen(words[i]); + for(int j = 0; j < length; i++) + { + if(islower(words[i][j])) + { + words[i][j] = toupper(words[i][j]); + } + } + words[i][MAX_WORD_LEN - 1] = '\0'; + + token = strtok(NULL, teiler); + i++; + } + + return i; } \ No newline at end of file -- 2.54.0 From 849d48aafa465c18558aaf513ca1c44b820edbea Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Mon, 26 Oct 2026 09:13:47 +0100 Subject: [PATCH 2/6] first version --- Startcode/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Startcode/input.c b/Startcode/input.c index 747448f..2ad13fc 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -21,7 +21,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) i++; } - return wordCount; + return i; //wordCount } static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN], unsigned int maxWordCount) @@ -38,7 +38,7 @@ static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN] strncpy(words[i], token, MAX_WORD_LEN - 1); //kleinbuchstaben --> GROßBUCHSTABEN int length = strlen(words[i]); - for(int j = 0; j < length; i++) + for(int j = 0; j < length; j++) { if(islower(words[i][j])) { -- 2.54.0 From a73810f61c3d26c160b89a10c8c43b97bd9c0696 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Mon, 26 Oct 2026 12:07:38 +0100 Subject: [PATCH 3/6] added new make cases to compile single modules --- Startcode/makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Startcode/makefile b/Startcode/makefile index 7cf1d4c..125e2e1 100644 --- a/Startcode/makefile +++ b/Startcode/makefile @@ -22,6 +22,15 @@ codefolder = . wordsalad_initial: $(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS) +# -------------------------- +# Zwischenstände +# -------------------------- +wordsalad_mymain: main.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a + $(CC) $(CFLAGS) -o wordsalad_mymain main.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS) + +wordsalad_myinput: input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a + $(CC) $(CFLAGS) -o wordsalad_myinput input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS) + # -------------------------- # Normales Spiel bauen # -------------------------- -- 2.54.0 From b685b56273cb57c9dcdb34726daf6bdd9137e754 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Mon, 26 Oct 2026 13:43:09 +0100 Subject: [PATCH 4/6] corrected issue at counting words --- Startcode/input.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Startcode/input.c b/Startcode/input.c index 2ad13fc..81b2433 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -12,16 +12,14 @@ static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN] int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { int wordCount = 0; - int i = 0; char lineRead[MAX_LINE_LEN]; - while(fgets(lineRead, MAX_LINE_LEN, file) != NULL && i < maxWordCount) + while(fgets(lineRead, MAX_LINE_LEN, file) != NULL && wordCount < (int)maxWordCount) { - wordCount += createSingleWords(lineRead, words, maxWordCount); - i++; + wordCount += createSingleWords(lineRead, words + wordCount, maxWordCount - wordCount); } - return i; //wordCount + return wordCount; //wordCount } static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN], unsigned int maxWordCount) -- 2.54.0 From 1a796d8144e82bad806cb64336b4f58a47445946 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Thu, 29 Oct 2026 22:10:33 +0100 Subject: [PATCH 5/6] added check of placed Words --- Startcode/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Startcode/main.c b/Startcode/main.c index 03da755..fbf9ad6 100644 --- a/Startcode/main.c +++ b/Startcode/main.c @@ -41,6 +41,23 @@ int main(int argc, char *argv[]) // Start the game if successful // error message if some words couldn't be placed + if(wordCount > 19) + { + if(placedWords != 20) + { + exitCode = EXIT_FAILURE; + printf("Only %d of %d possible words could be placed\n", placedWords, 20); + } + } + else + { + if(placedWords != wordCount) + { + exitCode = EXIT_FAILURE; + printf("Only %d of %d possible words could be placed\n", placedWords, wordCount); + } + } + } else { -- 2.54.0 From 594dd3c2ce08c8a8fabfce91a58df1dff30b3948 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Thu, 29 Oct 2026 22:11:52 +0100 Subject: [PATCH 6/6] changed return type of readWords() to unsigned int --- Startcode/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Startcode/input.c b/Startcode/input.c index 81b2433..65541fd 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -9,7 +9,7 @@ // Read words from file and store in 'words' array static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN], unsigned int maxWordCount); -int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) +unsigned int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { int wordCount = 0; char lineRead[MAX_LINE_LEN]; -- 2.54.0