This commit is contained in:
Giorgi Kesidis 2025-10-22 00:21:17 +02:00
parent db1e31f237
commit 6f3446fa8d
2 changed files with 10 additions and 8 deletions

View File

@ -12,7 +12,7 @@ int main(int argc, char *argv[])
int exitCode = EXIT_SUCCESS;
// Check if the correct number of arguments is provided
if(argc != 2)
if (argc != 2)
{
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
exitCode = EXIT_FAILURE;
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
FILE *file = fopen(argv[1], "r");
if(file != NULL)
if (file != NULL)
{
unsigned int placedWords = 0;
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
@ -40,11 +40,14 @@ int main(int argc, char *argv[])
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
if(wordCount != placedWords)
{
fprintf(stderr, "Error: %d out of %d were placed", placedWords, wordCount);
}
if (wordCount != placedWords)
{
fprintf(stderr, "Error: %u out of %u were placed\n", placedWords, wordCount);
}
else
{
startGame(wordSalad, SALAD_SIZE, words, placedWords, 800);
}
}
else
{
@ -52,7 +55,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]);
exitCode = EXIT_FAILURE;
}
startGame(words)
}
return exitCode;

Binary file not shown.