diff --git a/Start_Windows/game.c b/Start_Windows/game.c index 08b8025..9923771 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -115,6 +115,31 @@ int placeWord(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPositi return 1; } +// Places random letters into the +// empty fields of the wordSalad +void placeRandomLetters(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) +{ + int i = 0; + int j = 0; + + + srand(time(NULL)); + + for (i = 0; i < searchFieldLen; i++) + { + for (j = 0; i < searchFieldLen; j++) + { + if (salad[i][j]) + { + if ((salad[i][j] < 'A') && (salad[i][j] > 'z')) + { + salad[i][j] = rand()%('Z' - 'A' + 1) + 'A'; + } + } + } + } +} + // Creates the word salad by placing words randomly and filling empty spaces // returnes the number of sucessfully placed words @@ -143,6 +168,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi placedWords += placeWord(salad, currentWordPosition, currentWord, strlen(currentWord), searchFieldLen); } } + + placeRandomLetters(salad, searchFieldLen); return placedWords;