diff --git a/main.c b/main.c index de7df18..83686f0 100644 --- a/main.c +++ b/main.c @@ -1,8 +1,7 @@ #include #include +#include "main.h" -int getRandomNumber(); -int askForRepeat(); int running = 1; int main() @@ -39,28 +38,3 @@ int main() return 0; } - -int getRandomNumber(int limiter) -{ - return rand() % limiter; -} - -int askForRepeat() -{ - char nochmal; - printf("Willst du nochmal spielen?\n"); - scanf("%c", &nochmal); - if (nochmal == 'j') - { - return 1; - } - else if (nochmal == 'n') - { - return 0; - } - else - { - printf("Input konnte nicht gelesen werden\n"); - return askForRepeat(); - } -} \ No newline at end of file diff --git a/main.h b/main.h new file mode 100644 index 0000000..7ee30eb --- /dev/null +++ b/main.h @@ -0,0 +1,32 @@ +#ifndef main_h +#define main_h + +#include +#include + +int getRandomNumber(int limiter) +{ + return rand() % limiter; +} + +int askForRepeat() +{ + char nochmal; + printf("Willst du nochmal spielen?\n"); + scanf("%c", &nochmal); + if (nochmal == 'j') + { + return 1; + } + else if (nochmal == 'n') + { + return 0; + } + else + { + printf("Input konnte nicht gelesen werden\n"); + return askForRepeat(); + } +} + +#endif \ No newline at end of file