|
@ -51,7 +51,9 @@ void hangman() |
|
|
{ |
|
|
{ |
|
|
printf("Bitte gib einen Buchstaben ein!\n"); |
|
|
printf("Bitte gib einen Buchstaben ein!\n"); |
|
|
scanf(" %c", &userSelection); |
|
|
scanf(" %c", &userSelection); |
|
|
printf("%c\n", userSelection); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
letterGuessed(userSelection, guessWord, length, displayWord); |
|
|
|
|
|
printf("%s\n", displayWord); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}while(userSelection != '0'); |
|
|
}while(userSelection != '0'); |
|
@ -74,10 +76,33 @@ bool wordGuessed(char x[], char y[]) |
|
|
{ |
|
|
{ |
|
|
if(strcmp(x,y) == 0) |
|
|
if(strcmp(x,y) == 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
printf("Du hast gewonnen!\n"); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool letterGuessed(char x, char y[], int length, char ptr[]) |
|
|
|
|
|
{ |
|
|
|
|
|
int counter = 0; |
|
|
|
|
|
for(int i = 0; i<length; i++) { |
|
|
|
|
|
if (x == y[i]) { |
|
|
|
|
|
ptr[i] = x; |
|
|
|
|
|
printf("Dein gewählter Buchstabe %c war ein Treffer!\n", x); |
|
|
|
|
|
counter++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(counter>0) |
|
|
|
|
|
{ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |