Compare commits
No commits in common. "2d6643732438de68217e6406f500136da2fc4a18" and "6f3446fa8da1da8ea0924c72bd81d919f42c02ce" have entirely different histories.
2d66437324
...
6f3446fa8d
@ -8,30 +8,5 @@
|
|||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' array
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||||
{
|
{
|
||||||
//kein fopen und close nötig, weil dies schon in der main passiert und mit *file übergeben wird//
|
|
||||||
|
|
||||||
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
perror("Error invalid pointer to file");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char line[1024];
|
|
||||||
unsigned int count = 0;
|
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), file) && count < maxWordCount)
|
|
||||||
{
|
|
||||||
line[strcspn(line, "\n")] = '\0';
|
|
||||||
|
|
||||||
char *token = strtok(line, " ;,");
|
|
||||||
while (token && count < maxWordCount)
|
|
||||||
{
|
|
||||||
strcpy(words[count], token);
|
|
||||||
count++;
|
|
||||||
token = strtok(NULL, " ;,");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
startGame(wordSalad, SALAD_SIZE, words, placedWords, 1024);
|
startGame(wordSalad, SALAD_SIZE, words, placedWords, 800);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user