implementirung von den array voll leer machen
This commit is contained in:
parent
8592476b50
commit
65b20f7ea4
@ -15,7 +15,8 @@ void fillEmptySpots();
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// Creates the word salad by placing words randomly and filling empty spaces
|
||||||
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)
|
||||||
{
|
{
|
||||||
emptyArray(salad);
|
srand(time(NULL));
|
||||||
|
emptyArray(salad,MAX_SEARCH_FIELD_LEN * MAX_SEARCH_FIELD_LEN);
|
||||||
placeWord(salad,words);
|
placeWord(salad,words);
|
||||||
fillEmptySpots(salad);
|
fillEmptySpots(salad);
|
||||||
}
|
}
|
||||||
@ -23,17 +24,29 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
// Prints the word salad to console
|
// Prints the word salad to console
|
||||||
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
||||||
{
|
{
|
||||||
|
for(int i = 0; i <= MAX_SEARCH_FIELD_LEN; i++ )
|
||||||
|
{
|
||||||
|
for(int j = 0; j <= MAX_SEARCH_FIELD_LEN; j++)
|
||||||
|
{
|
||||||
|
printf("[%c]",salad[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void emptyArray(char array[][])
|
void emptyArray(char array[][], int arrayLength)
|
||||||
{
|
{
|
||||||
|
char* element = (char*) &array;
|
||||||
|
for(int i = 0; i < arrayLength; i++ )
|
||||||
|
{
|
||||||
|
*element = EMPTY_CHAR;
|
||||||
|
element++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int placeWord(char intoArray[][], char insertedWord[][])
|
int placeWord(char intoArray[][], char insertedWord[][])
|
||||||
{
|
{
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillEmptySpots(char useArray[][])
|
void fillEmptySpots(char useArray[][])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user