Fix gross klein

This commit is contained in:
Giorgi Kesidis 2025-10-27 20:35:05 +01:00
parent 63b1ccd0ea
commit 6f1a59af0c
5 changed files with 9 additions and 5 deletions

View File

@ -15,15 +15,14 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
{
// wipe field
int placedWords = 0;
for (int i = 0; searchFieldLen < i; i++)
for (int i = 0; i < searchFieldLen; i++)
{
for (int j = 0; searchFieldLen < j; i++)
for (int j = 0; j < searchFieldLen ; j++)
salad[i][j] = EMPTY_CHAR;
}
// place Words
for (int wordNumber = 0; wordNumber < wordCount; wordNumber++)
{
srand(time(NULL));
int wordlength = strlen(words[wordNumber]);
int placed = 0;
@ -74,7 +73,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
for (int i = 0; i < wordlength; i++) // position already occupied by other word
{
if (salad[y + 1][x] != EMPTY_CHAR)
if (salad[y + i][x] != EMPTY_CHAR)
{
fits = 0;
break;
@ -100,7 +99,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
{
if (salad[i][j] == EMPTY_CHAR)
{
salad[i][j] = (rand() % ((90 - 65) + 1)) + 65; // 90 ist Z in ASCII und A ist 65
salad[i][j] = rand() % ('Z' - 'A' + 1) + 'A'; // 90 ist Z in ASCII und A ist 65
}
}
}

Binary file not shown.

View File

@ -27,6 +27,11 @@ while (fgets(line, sizeof(line), file) && (count < maxWordCount))
char *token = strtok(line, " ;,");
while (token && (count < maxWordCount))
{
for (int i = 0; token[i] != '\0'; i++)
{
token[i] = toupper(token[i]);
}
strcpy(words[count], token);
count++;
token = strtok(NULL, " ;,");

Binary file not shown.

Binary file not shown.