included header file, not sure why tho lol
This commit is contained in:
28
main.c
28
main.c
@@ -1,8 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
int getRandomNumber();
|
|
||||||
int askForRepeat();
|
|
||||||
int running = 1;
|
int running = 1;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@@ -39,28 +38,3 @@ int main()
|
|||||||
|
|
||||||
return 0;
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
32
main.h
Normal file
32
main.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef main_h
|
||||||
|
#define main_h
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user