Compare commits

...

2 Commits

Author SHA1 Message Date
be5b6adc0b main.c fertig angepasst 2025-10-26 20:35:02 +01:00
46a71de3ec input.c fertig in Start_Mac 2025-10-26 20:20:40 +01:00
2 changed files with 16 additions and 3 deletions

View File

@ -11,6 +11,7 @@
* @return Anzahl der eingelesenen Wörter * @return Anzahl der eingelesenen Wörter
*/ */
// Read words from file and store in 'words' array // Read words from file and store in 'words' array
// ERLEDIGT
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{ {
if (file == NULL || words == NULL || maxWordCount == 0) { if (file == NULL || words == NULL || maxWordCount == 0) {

View File

@ -37,10 +37,22 @@ int main(int argc, char *argv[])
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// TODO: // TODO:
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
// Check if all words were successfully placed
if(placedWords == wordCount)
{
// Start the game if successful
printf("All %u words were successfully placed in the word salad!\n", wordCount);
createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
showWordSalad(wordSalad, SALAD_SIZE);
}
else
{
// Error message if some words couldn't be placed
fprintf(stderr, "Error: Only %u out of %u words could be placed in the word salad.\n",
placedWords, wordCount);
exitCode = EXIT_FAILURE;
}
} }
else else
{ {