Update feat/game from main

This commit is contained in:
Andreas Binner committed 2026-10-30 07:44:43 +01:00
commit 3b6914dc8e
3 files changed
+19 -2

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@
// Read words from file and store in 'words' array
static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN], unsigned int maxWordCount);
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
unsigned int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
int wordCount = 0;
char lineRead[MAX_LINE_LEN];
+1 -1
View File
@@ -6,6 +6,6 @@
#define MAX_WORD_LEN 100
#define MAX_LINE_LEN 1024
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
unsigned int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
#endif
+17
View File
@@ -41,6 +41,23 @@ int main(int argc, char *argv[])
// Start the game if successful
// error message if some words couldn't be placed
if(wordCount > 19)
{
if(placedWords != 20)
{
exitCode = EXIT_FAILURE;
printf("Only %d of %d possible words could be placed\n", placedWords, 20);
}
}
else
{
if(placedWords != wordCount)
{
exitCode = EXIT_FAILURE;
printf("Only %d of %d possible words could be placed\n", placedWords, wordCount);
}
}
}
else
{