diff --git a/Startcode/game.c b/Startcode/game.c index d49b8e9..1ba6d5a 100644 --- a/Startcode/game.c +++ b/Startcode/game.c @@ -16,12 +16,21 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi //Initialisiert den seed für rand() srand(time(NULL)); + //Initialisiere spielfeld auf '0' + // TODO: memset() + for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++){ + for (int j = 0; j < MAX_SEARCH_FIELD_LEN; j++){ + salad[i][j] = '0'; + } + } + int placedWords = 0; //Iterate over words unsigned int counter = 0; while(counter < wordCount){ //load current word - char currentWord[MAX_WORD_LEN] = words[counter]; + char currentWord[MAX_WORD_LEN]; + strncpy(currentWord) //try to place a word int try = 0; @@ -29,8 +38,10 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi int x = rand() % MAX_SEARCH_FIELD_LEN; int y = rand() % MAX_SEARCH_FIELD_LEN; + if (salad[x][y] == '0'){ + + } - try++; } }