1 Commits
+7 -3
View File
@@ -8,7 +8,7 @@
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
{ {
int row, col, word, startcol=0, startrow=0; int row, col, word, startcol=0, startrow=0, placedWord=0;
srand(time(NULL)); srand(time(NULL));
for(row=0; row<MAX_SEARCH_FIELD_LEN; row++) for(row=0; row<MAX_SEARCH_FIELD_LEN; row++)
{ {
@@ -38,7 +38,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
salad[startrow+j][startcol] = words[word][j]; salad[startrow+j][startcol] = words[word][j];
} }
} }
placedWord++;
if (rand()%26 !=0) if (rand()%26 !=0)
{ {
printf("%c",EMPTY_CHAR); printf("%c",EMPTY_CHAR);
@@ -65,5 +65,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
printf("\n"); printf("\n");
} }
printf("\n\nPlatzierung abgeschlossen\n\n"); printf("\n\nPlatzierung abgeschlossen\n\n");
return 0;
if(placedWord==word)
{
return placedWord;
} else return 0;
} }