|
@ -1,32 +1,56 @@ |
|
|
#include <stdio.h> |
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
#include "structs.h" |
|
|
|
|
|
#include "functions.h" |
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
|
|
|
|
void startGame(int catCount, char* input, Category* categories) |
|
|
{ |
|
|
{ |
|
|
const char* question; |
|
|
|
|
|
char answer[256]; |
|
|
|
|
|
} Question; |
|
|
|
|
|
|
|
|
int questCount = 0; |
|
|
|
|
|
int curCatNum = 0; |
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
|
{ |
|
|
|
|
|
int size; |
|
|
|
|
|
Question questions[12]; |
|
|
|
|
|
} Level; |
|
|
|
|
|
|
|
|
int level = 0; |
|
|
|
|
|
int score = 0; |
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
|
{ |
|
|
|
|
|
int size; |
|
|
|
|
|
const char* name; |
|
|
|
|
|
Level lvlQuestions[10]; |
|
|
|
|
|
} Category; |
|
|
|
|
|
|
|
|
for (int i = 0; i < catCount; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
Level lvlQuestions[10]; |
|
|
|
|
|
memcpy(lvlQuestions, categories[i].lvlQuestions, sizeof(categories[i].lvlQuestions)); |
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
|
{ |
|
|
|
|
|
int score = 0; |
|
|
|
|
|
int level = 0; |
|
|
|
|
|
|
|
|
printf("Kategorie %s\n", categories[i].name); |
|
|
|
|
|
|
|
|
char input[256]; |
|
|
|
|
|
|
|
|
while (level < sizeof(lvlQuestions) / sizeof(Level)) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < lvlQuestions[level].size; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
printf(lvlQuestions[level].questions[i].question); |
|
|
|
|
|
printf(" "); |
|
|
|
|
|
fgets(input, 256, stdin); |
|
|
|
|
|
input[strlen(input) - 1] = '\0'; |
|
|
|
|
|
const char* buf = lvlQuestions[level].questions[i].answer; |
|
|
|
|
|
if (compareStrings(input, buf)) |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Falsch. Die richtige Antwort ist: %s.\n", lvlQuestions[level].questions[i].answer); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Richtig!\n"); |
|
|
|
|
|
score++; |
|
|
|
|
|
} |
|
|
|
|
|
resetInput(input); |
|
|
|
|
|
questCount++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
printf("Level %d abgeschlossen!\n", level + 1); |
|
|
|
|
|
level++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
level = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Ergebnis |
|
|
|
|
|
printEndMsg(score, questCount); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
|
{ |
|
|
Question fussQst1 = {.question = "Welche Fussballmannschaft wurde 1930 Weltmeister?", .answer = "Uruguay"}; |
|
|
Question fussQst1 = {.question = "Welche Fussballmannschaft wurde 1930 Weltmeister?", .answer = "Uruguay"}; |
|
|
Question fussQst2 = {.question = "Welche Fussballmannschaft wurde 1934 Weltmeister?", .answer = "Italien"}; |
|
|
Question fussQst2 = {.question = "Welche Fussballmannschaft wurde 1934 Weltmeister?", .answer = "Italien"}; |
|
|
Question fussQst3 = {.question = "Welche Fussballmannschaft wurde 1938 Weltmeister?", .answer = "Italien"}; |
|
|
Question fussQst3 = {.question = "Welche Fussballmannschaft wurde 1938 Weltmeister?", .answer = "Italien"}; |
|
@ -262,49 +286,10 @@ int main() |
|
|
|
|
|
|
|
|
printf("Willkommen beim Quiz-Spiel! Beantworten Sie die folgenden Fragen:\n"); |
|
|
printf("Willkommen beim Quiz-Spiel! Beantworten Sie die folgenden Fragen:\n"); |
|
|
|
|
|
|
|
|
int questCount = 0; |
|
|
|
|
|
int curCatNum = 0; |
|
|
|
|
|
int catCount = 1; // anzahl an kategorien |
|
|
int catCount = 1; // anzahl an kategorien |
|
|
|
|
|
char input[256]; |
|
|
|
|
|
|
|
|
for (int i = 0; i < catCount; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
Level lvlQuestions[10]; |
|
|
|
|
|
memcpy(lvlQuestions, categories[i].lvlQuestions, sizeof(categories[i].lvlQuestions)); |
|
|
|
|
|
|
|
|
|
|
|
printf("Kategorie %s\n", categories[i].name); |
|
|
|
|
|
|
|
|
|
|
|
while (level < sizeof(lvlQuestions) / sizeof(Level)) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < lvlQuestions[level].size; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
printf(lvlQuestions[level].questions[i].question); |
|
|
|
|
|
printf(" "); |
|
|
|
|
|
fgets(input, 256, stdin); |
|
|
|
|
|
input[strlen(input) - 1] = '\0'; |
|
|
|
|
|
const char* buf = lvlQuestions[level].questions[i].answer; |
|
|
|
|
|
if (strcmp(input, buf)) |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Falsch. Die richtige Antwort ist: %s.\n", lvlQuestions[level].questions[i].answer); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Richtig!\n"); |
|
|
|
|
|
score++; |
|
|
|
|
|
} |
|
|
|
|
|
memset(&input[0], 0, sizeof(input)); |
|
|
|
|
|
|
|
|
|
|
|
questCount++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
printf("Level %d abgeschlossen!\n", level + 1); |
|
|
|
|
|
level++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
level = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Ergebnis |
|
|
|
|
|
printf("Sie haben %d von %d Fragen richtig beantwortet.\n", score, questCount); |
|
|
|
|
|
|
|
|
startGame(catCount, input, categories); |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |