From d3880981729b54656e3bd33dda9b2696515221e4 Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 29 Jan 2024 15:53:07 +0100 Subject: [PATCH] getBalance erweitert mit userInput --- src/main/c/Stefan/slot_machine.c | 9 ++++++++- src/main/c/Stefan/slot_machine.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index f0ee169..ff07038 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -17,10 +17,17 @@ void slotMachine(){ int getBalance(){ int balance; printf("Guthaben einwerfen: "); - scanf_s("%d", &balance); + balance = userInput(); + printf("Dein Guthaben: %d", balance); return balance; } +int userInput(){ + int input; + scanf_s("%d", &input); + return input; +} + void welcomeMessage(){ printf("Herzlich Willkommen zur \n\n" " _ _ _ _ \n" diff --git a/src/main/c/Stefan/slot_machine.h b/src/main/c/Stefan/slot_machine.h index 3da8ff8..56cebac 100644 --- a/src/main/c/Stefan/slot_machine.h +++ b/src/main/c/Stefan/slot_machine.h @@ -4,6 +4,6 @@ void slotMachine(); void welcomeMessage(); int getBalance(); - +int userInput(); #endif // SLOT_MACHINE_H \ No newline at end of file