From 1a796d8144e82bad806cb64336b4f58a47445946 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Thu, 29 Oct 2026 22:10:33 +0100 Subject: [PATCH 1/4] 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 { From 594dd3c2ce08c8a8fabfce91a58df1dff30b3948 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Thu, 29 Oct 2026 22:11:52 +0100 Subject: [PATCH 2/4] 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]; From 9967eb3b09cf3c3eec4422feb9722d51cc77c708 Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Thu, 29 Oct 2026 22:26:50 +0100 Subject: [PATCH 3/4] fixed error in return type input.h --- Startcode/input.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Startcode/input.h b/Startcode/input.h index 032ec28..265de42 100644 --- a/Startcode/input.h +++ b/Startcode/input.h @@ -6,6 +6,6 @@ #define MAX_WORD_LEN 100 #define MAX_LINE_LEN 1024 -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); #endif From ab3d269759a6fc1f38f9258496ab6f0488bee33a Mon Sep 17 00:00:00 2001 From: Andreas Binner Date: Fri, 30 Oct 2026 09:45:10 +0100 Subject: [PATCH 4/4] changed numbers to variable --- Startcode/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Startcode/main.c b/Startcode/main.c index fbf9ad6..7152f65 100644 --- a/Startcode/main.c +++ b/Startcode/main.c @@ -41,9 +41,9 @@ int main(int argc, char *argv[]) // Start the game if successful // error message if some words couldn't be placed - if(wordCount > 19) + if(wordCount >= SALAD_SIZE) { - if(placedWords != 20) + if(placedWords != SALAD_SIZE) { exitCode = EXIT_FAILURE; printf("Only %d of %d possible words could be placed\n", placedWords, 20);