53 lines
2.2 KiB
C
53 lines
2.2 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "input.h"
|
|
#include "game.h"
|
|
#include "graphicalGame.h"
|
|
|
|
#define MAX_NUMBER_OF_WORDS 100
|
|
#define SALAD_SIZE 20
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
int exitCode = EXIT_SUCCESS;
|
|
|
|
if (argc != 2) //wenn keine zwei argumente gefunde -> alarm
|
|
{
|
|
fprintf(stderr, "Benutzung: %s <Pfad zur Wörterdatei>\n", argv[0]);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN]; //array mit eingelesenen wörtern
|
|
unsigned int wordCount = 0;
|
|
|
|
FILE *file = fopen(argv[1], "r"); //schaut in die words.txt datei
|
|
if (!file) //wenn keine datei -> alarm
|
|
{
|
|
fprintf(stderr, "Konnte Datei %s nicht öffnen.\n", argv[1]);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
unsigned int placedWords = 0;
|
|
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
|
|
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS); //holt sich aus readwords funktion die wortanzahl
|
|
fclose(file);
|
|
|
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); //holt sich anzahl der platzierten wörter von createwordsalad funktion
|
|
|
|
printf("\nWortsalat-Initialisierung\n"); //ganz viel printen
|
|
printf("-------------------------\n");
|
|
printf("Gelesene Woerter: %u\n", wordCount);
|
|
printf("Platzierte Woerter: %u\n", placedWords);
|
|
|
|
if (placedWords < wordCount) //macht checker, ob alle wörter salatiert wurden
|
|
printf("Hinweis: %u Woerter konnten nicht platziert werden.\n", wordCount - placedWords);
|
|
|
|
printf("\nSpielfeld (%dx%d):\n\n", SALAD_SIZE, SALAD_SIZE);
|
|
showWordSalad(wordSalad, SALAD_SIZE);
|
|
printf("\nInitialisierung abgeschlossen.\n");
|
|
return exitCode;
|
|
} |