diff --git a/Start_Mac/game.c b/Start_Mac/game.c index afe388a..6d9b59d 100644 --- a/Start_Mac/game.c +++ b/Start_Mac/game.c @@ -31,6 +31,14 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi int voll = 0; int tries = 0; + for (int i = 0; i < MAX_SEARCH_FIELD_LEN; i++) + { + for (int j = 0; j < MAX_SEARCH_FIELD_LEN; j++) + { + salad[i][j] = EMPTY_CHAR; + } + } + if (vertikal_horizontal == VERTIKAL) { tries = 0; @@ -39,7 +47,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi positionX = rand() % (searchFieldLen); positionY = rand() % (searchFieldLen-leange); for(int j = positionY; j < positionY+leange ; j++) { //überprüfung ob alle positionen 0 sind - if(salad[j][positionX] != '0') { + if(salad[j][positionX] != EMPTY_CHAR) { voll = 1; } } @@ -51,7 +59,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi } placedWordsCount++; } else if (voll == 1) - printf("Das Wort '%s' konnte nicht plaziert werden", words[i]); + printf("Das Wort '%s' konnte nicht plaziert werden\n", words[i]); } else if (vertikal_horizontal == HORIZONTAL) { @@ -61,7 +69,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi positionY = rand() % (searchFieldLen); positionX = rand() % (searchFieldLen-leange); for(int j = positionX; j < positionX+leange ; j++) { //überprüfung ob alle positionen 0 sind - if(salad[positionY][j] != '0') { + if(salad[positionY][j] != EMPTY_CHAR) { voll = 1; } } @@ -73,7 +81,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi } placedWordsCount++; } else if (voll == 1) - printf("Das Wort '%s' konnte nicht plaziert werden", words[i]); + printf("Das Wort '%s' konnte nicht plaziert werden\n", words[i]); } else printf("Fehler bei Vertikal Horizontal Wert: %d", vertikal_horizontal); @@ -81,7 +89,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi for(int i = 0; i < searchFieldLen; i++) { for(int j = 0; j < searchFieldLen; j++) { - if(salad[i][j] == '0') { + if(salad[i][j] == EMPTY_CHAR) { salad[i][j] = buchstaben[rand() % anzahlBuchstaben]; } } diff --git a/Start_Mac/game.o b/Start_Mac/game.o index 6d3f9e2..8584adc 100644 Binary files a/Start_Mac/game.o and b/Start_Mac/game.o differ diff --git a/Start_Mac/main.c b/Start_Mac/main.c index 4ff149a..856b509 100644 --- a/Start_Mac/main.c +++ b/Start_Mac/main.c @@ -28,11 +28,6 @@ int main(int argc, char *argv[]) { unsigned int placedWords = 0; char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad - for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++) { - for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++) { - wordSalad[i][j] = '0'; - } - } // Read words from file and store in 'words' array wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS); diff --git a/Start_Mac/main.o b/Start_Mac/main.o index 035cd2c..2feae68 100644 Binary files a/Start_Mac/main.o and b/Start_Mac/main.o differ diff --git a/Start_Mac/wordsalad b/Start_Mac/wordsalad index 769a27d..a7dcfd0 100755 Binary files a/Start_Mac/wordsalad and b/Start_Mac/wordsalad differ