input funktion stand 24.10

This commit is contained in:
Giorgi Kesidis 2025-10-24 13:59:35 +02:00
parent 1c919cb6e3
commit 2d66437324
3 changed files with 27 additions and 2 deletions

View File

@ -8,5 +8,30 @@
// Read words from file and store in 'words' array
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;
}

View File

@ -46,7 +46,7 @@ int main(int argc, char *argv[])
}
else
{
startGame(wordSalad, SALAD_SIZE, words, placedWords, 800);
startGame(wordSalad, SALAD_SIZE, words, placedWords, 1024);
}
}
else

Binary file not shown.