generated from freudenreichan/info2Praktikum-Wortsalat
Update feat/game from main
This commit is contained in:
commit
3b6914dc8e
3 files changed
+19
-2
No files matched your search
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
// Read words from file and store in 'words' array
|
// 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);
|
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;
|
int wordCount = 0;
|
||||||
char lineRead[MAX_LINE_LEN];
|
char lineRead[MAX_LINE_LEN];
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,6 @@
|
|||||||
#define MAX_WORD_LEN 100
|
#define MAX_WORD_LEN 100
|
||||||
#define MAX_LINE_LEN 1024
|
#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
|
#endif
|
||||||
@@ -41,6 +41,23 @@ int main(int argc, char *argv[])
|
|||||||
// Start the game if successful
|
// Start the game if successful
|
||||||
// error message if some words couldn't be placed
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user