diff --git a/.gitignore b/.gitignore index 7c04e4b0..1e9f25b6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ newlib/examples/hello newlib/examples/jacobi newlib/examples/echo newlib/examples/tests +newlib/examples/hangman newlib/tmp/* newlib/x86/* metalsvm.elf diff --git a/kernel/tests.c b/kernel/tests.c index 4c0d87a9..4ba43b9f 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -119,7 +119,7 @@ static int STDCALL join_test(void* arg) int test_init(void) { - char* argv[] = {"/bin/hello", NULL}; + char* argv[] = {"/bin/hangman", NULL}; sem_init(&producing, 1); sem_init(&consuming, 0); @@ -131,7 +131,7 @@ int test_init(void) //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, ping, NULL); //create_user_task(NULL, "/bin/hello", argv); - create_user_task(NULL, "/bin/hello", argv); + create_user_task(NULL, "/bin/hangman", argv); //create_user_task(NULL, "/bin/jacobi", argv); return 0; diff --git a/newlib/examples/Makefile b/newlib/examples/Makefile index e1a373f9..f63906cb 100644 --- a/newlib/examples/Makefile +++ b/newlib/examples/Makefile @@ -11,7 +11,7 @@ LDFLAGS = default: all -all: hello tests jacobi +all: hello tests jacobi hangman jacobi: jacobi.o $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm @@ -31,6 +31,13 @@ hello: hello.o $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ chmod a-x $@.sym +hangman: hangman.o + $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< + $(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + chmod a-x $@.sym + + clean: $(RM) hello tests *.sym *.o *~ diff --git a/newlib/examples/hangman.c b/newlib/examples/hangman.c new file mode 100644 index 00000000..e558b0ef --- /dev/null +++ b/newlib/examples/hangman.c @@ -0,0 +1,41 @@ +#include +#include +#include + +int Spiel () +{ + //Variablen + + char* Wort = malloc(100*sizeof(char)); + char* Raten = malloc(100*sizeof(char));; + int Versuche = 10; + + printf("Spieler 1 geben sie das Wort ein :"); + scanf("%s", Wort); + + printf("\n\nNun, Spieler 2 errate bitte das Wort\n"); + + while(Raten!=Wort && Versuche > 0){ + printf("Deine Antwort:"); + scanf("%s", Raten); + + + if(!strcmp(Raten,Wort)) + { + printf("ToLL! Das Wort ist richtig"); + return 0; + } + else + { + printf("Schade das Wort ist falsch"); + } + Versuche--; + } + return 0; +}//Spielen + +int main(int argc, char** argv) +{ + Spiel(); +} + diff --git a/newlib/examples/test b/newlib/examples/test index 28d14454..e7cf92e9 100644 --- a/newlib/examples/test +++ b/newlib/examples/test @@ -1 +1,3 @@ -123456789 +test +hallo +huso