forked from freudenreichan/info2Praktikum-Wortsalat
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0bd8b46ea |
No files matched your search
@@ -39,7 +39,6 @@ Startcode/wordsalad_myversion
|
||||
Startcode/wordsalad_initial
|
||||
Startcode/wordsalad
|
||||
runtest
|
||||
test
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
|
||||
+7
-3
@@ -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 row, col, word, startcol=0, startrow=0;
|
||||
int row, col, word, startcol=0, startrow=0, placedWord=0;
|
||||
srand(time(NULL));
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
placedWord++;
|
||||
if (rand()%26 !=0)
|
||||
{
|
||||
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\nPlatzierung abgeschlossen\n\n");
|
||||
return word;
|
||||
|
||||
if(placedWord==word)
|
||||
{
|
||||
return placedWord;
|
||||
} else return 0;
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ unsigned int count = 0;
|
||||
|
||||
while (fgets(line, sizeof(line), file) != NULL && count < maxWordCount) {
|
||||
char *token = strtok(line, " ,;\n\r\t");
|
||||
while (token != NULL && count < maxWordCount) {
|
||||
while (token != NULL & count < maxWordCount) {
|
||||
if (strlen(token) > 0) {
|
||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user