From fbf443e02d8b84fadfce6a8aadcbc28bb50ec11b Mon Sep 17 00:00:00 2001 From: lukas Date: Fri, 16 Oct 2026 19:45:30 +0200 Subject: [PATCH] fixed null termination bug --- Startcode/game.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Startcode/game.c b/Startcode/game.c index 2e61e5b..ac5918f 100644 --- a/Startcode/game.c +++ b/Startcode/game.c @@ -15,8 +15,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi const char words[][MAX_WORD_LEN], unsigned int wordCount) { srand(time(NULL)); - for(int i = 0; i < searchFieldLen; i++){ - for(int j = 0; i < searchFieldLen; i++){ + for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){ + for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++){ salad[i][j] = 1; } } @@ -60,9 +60,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi } } //fill remaining spots with random chars - for(int i = 0; i < searchFieldLen; i++){ - for(int j = 0; j < searchFieldLen; j++){ - salad[i][j] = salad[i][j] == 1 ? (rand() % 25) + 65 : salad[i][j]; + for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){ + for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++){ + salad[i][j] = (salad[i][j] == 1) || (salad[i][j] == 0) ? (rand() % 25) + 65 : salad[i][j]; } } return wordCount - failed;