Browse Source

Hinzufügen des Displaywortes

remotes/origin/tim
fdai7727 11 months ago
parent
commit
0ace76ce85
  1. 14
      src/main/c/Tim/hangman.c

14
src/main/c/Tim/hangman.c

@ -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);

Loading…
Cancel
Save