add tiny hangman test
This commit is contained in:
parent
8651593758
commit
bae6e2df51
5 changed files with 55 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -17,6 +17,7 @@ newlib/examples/hello
|
||||||
newlib/examples/jacobi
|
newlib/examples/jacobi
|
||||||
newlib/examples/echo
|
newlib/examples/echo
|
||||||
newlib/examples/tests
|
newlib/examples/tests
|
||||||
|
newlib/examples/hangman
|
||||||
newlib/tmp/*
|
newlib/tmp/*
|
||||||
newlib/x86/*
|
newlib/x86/*
|
||||||
metalsvm.elf
|
metalsvm.elf
|
||||||
|
|
|
@ -119,7 +119,7 @@ static int STDCALL join_test(void* arg)
|
||||||
|
|
||||||
int test_init(void)
|
int test_init(void)
|
||||||
{
|
{
|
||||||
char* argv[] = {"/bin/hello", NULL};
|
char* argv[] = {"/bin/hangman", NULL};
|
||||||
|
|
||||||
sem_init(&producing, 1);
|
sem_init(&producing, 1);
|
||||||
sem_init(&consuming, 0);
|
sem_init(&consuming, 0);
|
||||||
|
@ -131,7 +131,7 @@ int test_init(void)
|
||||||
//create_kernel_task(NULL, consumer, NULL);
|
//create_kernel_task(NULL, consumer, NULL);
|
||||||
//create_kernel_task(NULL, ping, 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/hello", argv);
|
create_user_task(NULL, "/bin/hangman", argv);
|
||||||
//create_user_task(NULL, "/bin/jacobi", argv);
|
//create_user_task(NULL, "/bin/jacobi", argv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,7 +11,7 @@ LDFLAGS =
|
||||||
|
|
||||||
default: all
|
default: all
|
||||||
|
|
||||||
all: hello tests jacobi
|
all: hello tests jacobi hangman
|
||||||
|
|
||||||
jacobi: jacobi.o
|
jacobi: jacobi.o
|
||||||
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm
|
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm
|
||||||
|
@ -31,6 +31,13 @@ hello: hello.o
|
||||||
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
|
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
|
||||||
chmod a-x $@.sym
|
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:
|
clean:
|
||||||
$(RM) hello tests *.sym *.o *~
|
$(RM) hello tests *.sym *.o *~
|
||||||
|
|
||||||
|
|
41
newlib/examples/hangman.c
Normal file
41
newlib/examples/hangman.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
123456789
|
test
|
||||||
|
hallo
|
||||||
|
huso
|
||||||
|
|
Loading…
Add table
Reference in a new issue