diff --git a/src/wwm.c b/src/wwm.c index e15b08e..849d60d 100644 --- a/src/wwm.c +++ b/src/wwm.c @@ -8,6 +8,8 @@ int geld = 0; int frage = 0; int useranswer; +int ceingabe(); + int setGeld(int runde){ int Geldstufen[] = {0, 100, 200, 300, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 125000, 250000, 500000, 1000000}; geld = Geldstufen[runde]; @@ -22,10 +24,24 @@ int crandomNumber() { } + +void ccheckAnswer(int useranswer) { + if (useranswer == 5) { + printf("That is a shame, but ok.\n"); + printf("Congratulations! You have won %d $!", geld); + exit(0); + } +} + int ceingabe() { printf("Your answer (1-4):"); - scanf("%d", &useranswer); - return useranswer; + int result = scanf_s("%d", &useranswer); + if (result == 0) { + printf("Please enter a number beetween 1 and 4 to answer or 5 to end the game!\n"); + while (getchar() != '\n') + return ceingabe(); + return useranswer; + } }; void wwm(){ diff --git a/src/wwm.h b/src/wwm.h index ab4ba12..3a461f8 100644 --- a/src/wwm.h +++ b/src/wwm.h @@ -10,6 +10,7 @@ extern int Geldstufen[]; int crandomNumber(); int ceingabe(); +void ccheckAnswer(); int setGeld(int runde);