diff --git a/Startcode/input.c b/Startcode/input.c index 81b2433..65541fd 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -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]; diff --git a/Startcode/input.h b/Startcode/input.h index 032ec28..265de42 100644 --- a/Startcode/input.h +++ b/Startcode/input.h @@ -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 diff --git a/Startcode/main.c b/Startcode/main.c index 03da755..fbf9ad6 100644 --- a/Startcode/main.c +++ b/Startcode/main.c @@ -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 {