generated from freudenreichan/info2Praktikum-Wortsalat
Letzter Feinschliff2
This commit is contained in:
1 parent
7f3e18becf
commit
6977a72ae7
2 files changed
+17
-28
No files matched your search
+9
-7
@@ -46,12 +46,14 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MIT HILFE VON KI ZUR KONTROLLE GEMACHT: Konsolenausgabe zur Kontrolle der eingelesenen Wörter
|
/*
|
||||||
printf("Eingelesene Woerter (%u Stueck):\n", i);
|
// MIT HILFE VON KI ZUR KONTROLLE GEMACHT: Konsolenausgabe zur Kontrolle der eingelesenen Wörter
|
||||||
for (unsigned int idx = 0; idx < i; idx++)
|
printf("Eingelesene Woerter (%u Stueck):\n", i);
|
||||||
{
|
for (unsigned int idx = 0; idx < i; idx++)
|
||||||
printf("%u. Entry: %s\n", idx + 1, words[idx]);
|
{
|
||||||
}
|
printf("%u. Entry: %s\n", idx + 1, words[idx]);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return (int)i;
|
return (int)i;
|
||||||
}
|
}
|
||||||
+8
-21
@@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
#define MAX_NUMBER_OF_WORDS 100
|
#define MAX_NUMBER_OF_WORDS 100
|
||||||
#define SALAD_SIZE 20
|
#define SALAD_SIZE 20
|
||||||
#define WINDOW_WIDTH 800 //KI hat 800 geraten mal sehen ob es passt
|
#define WINDOW_WIDTH 800 // KI hat 800 geraten mal sehen ob es passt
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int exitCode = EXIT_SUCCESS;
|
int exitCode = EXIT_SUCCESS;
|
||||||
|
|
||||||
// Check if the correct number of arguments is provided
|
// 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]);
|
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
|
||||||
exitCode = EXIT_FAILURE;
|
exitCode = EXIT_FAILURE;
|
||||||
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
FILE *file = fopen(argv[1], "r");
|
FILE *file = fopen(argv[1], "r");
|
||||||
|
|
||||||
if(file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
unsigned int placedWords = 0;
|
unsigned int placedWords = 0;
|
||||||
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
|
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
|
||||||
@@ -37,38 +37,25 @@ int main(int argc, char *argv[])
|
|||||||
// Create the word salad by placing words into grid
|
// Create the word salad by placing words into grid
|
||||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||||
|
|
||||||
|
|
||||||
if (wordCount == 0)
|
if (wordCount == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Keine Woerter in %s gefunden.\n", argv[1]);
|
fprintf(stderr, "Keine Woerter in %s gefunden.\n", argv[1]);
|
||||||
exitCode = EXIT_FAILURE;
|
exitCode = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prüfung ob manche Wörter nicht platziert wurden
|
// Prüfung ob manche Wörter nicht platziert wurden
|
||||||
else if(placedWords != wordCount){
|
else if (placedWords != wordCount)
|
||||||
|
{
|
||||||
|
|
||||||
fprintf(stderr, "Es konnten nur %u von %u Woertern platziert werden, such den Fehler\n", placedWords, wordCount);
|
fprintf(stderr, "Es konnten nur %u von %u Woertern platziert werden, such den Fehler\n", placedWords, wordCount);
|
||||||
exitCode = EXIT_FAILURE;
|
exitCode = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sonst alles erfolgreich verlaufen
|
// sonst alles erfolgreich verlaufen
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
startGame(wordSalad, SALAD_SIZE, words, wordCount, WINDOW_WIDTH);
|
startGame(wordSalad, SALAD_SIZE, words, wordCount, WINDOW_WIDTH);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user