|
@ -23,11 +23,23 @@ void hangman() |
|
|
do |
|
|
do |
|
|
{ |
|
|
{ |
|
|
char guessWord[30]; |
|
|
char guessWord[30]; |
|
|
|
|
|
char displayWord[30]; |
|
|
int length; |
|
|
int length; |
|
|
strcpy(guessWord,wordlist[rand() % 10]); |
|
|
strcpy(guessWord,wordlist[rand() % 10]); |
|
|
length = strlen(guessWord); |
|
|
length = strlen(guessWord); |
|
|
printf("%s %d\n",guessWord, length); |
|
|
printf("%s %d\n",guessWord, length); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= length; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
if(i<length) |
|
|
|
|
|
{ |
|
|
|
|
|
displayWord[i] = '_'; |
|
|
|
|
|
} |
|
|
|
|
|
else if(i == length) |
|
|
|
|
|
{ |
|
|
|
|
|
displayWord[i] = '\0'; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
printf("%s\n", displayWord); |
|
|
|
|
|
|
|
|
printf("Bitte gib einen Buchstaben ein!\n"); |
|
|
printf("Bitte gib einen Buchstaben ein!\n"); |
|
|
scanf(" %c", &userSelection); |
|
|
scanf(" %c", &userSelection); |
|
|