From e7a9876c98a9dc7f3bd378f6dc0ae8b4240c6a94 Mon Sep 17 00:00:00 2001 From: Christian Reum Date: Tue, 6 Feb 2024 19:08:05 +0100 Subject: [PATCH] functional 18: checkAnswer (useranswer nicht <> 1-4) --- src/wwm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wwm.c b/src/wwm.c index 2d7bffc..b987eca 100644 --- a/src/wwm.c +++ b/src/wwm.c @@ -31,6 +31,10 @@ void ccheckAnswer(int useranswer) { printf("Congratulations! You have won %d $!", geld); exit(0); } + if (useranswer < 1 || useranswer > 4) { + printf("Please enter a number beetween 1 and 4 or enter 5 to end the game!\n"); + ceingabe(); + } } int ceingabe() { @@ -40,7 +44,8 @@ int ceingabe() { 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; + ccheckAnswer(useranswer); + return useranswer; } };