|
|
@ -54,6 +54,7 @@ void hangman() |
|
|
|
scanf(" %c", &userSelection); |
|
|
|
|
|
|
|
letterGuessed(userSelection, guessWord, length, displayWord); |
|
|
|
changeLetter(userSelection, guessWord, length, displayWord); |
|
|
|
printf("%s\n", displayWord); |
|
|
|
} |
|
|
|
|
|
|
@ -90,6 +91,37 @@ bool wordGuessed(char x[], char y[]) |
|
|
|
bool letterGuessed(char x, char y[], int length, char ptr[]) |
|
|
|
{ |
|
|
|
int counter = 0; |
|
|
|
for(int i = 0; i<length; i++) { |
|
|
|
if(isupper(x)!=0) |
|
|
|
{ |
|
|
|
if (x == y[i]-32 || x == y[i] ) |
|
|
|
{ |
|
|
|
counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (x == y[i]||x == y[i]+32) |
|
|
|
{ |
|
|
|
counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(counter>0) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void changeLetter(char x, char y[], int length, char ptr[]) |
|
|
|
{ |
|
|
|
for(int i = 0; i<length; i++) { |
|
|
|
if(isupper(x)!=0) |
|
|
|
{ |
|
|
@ -104,7 +136,6 @@ bool letterGuessed(char x, char y[], int length, char ptr[]) |
|
|
|
ptr[i] = x+32; |
|
|
|
} |
|
|
|
printf("Dein gewaehlter Buchstabe %c war ein Treffer!\n", x); |
|
|
|
counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
@ -119,18 +150,7 @@ bool letterGuessed(char x, char y[], int length, char ptr[]) |
|
|
|
ptr[i] = x; |
|
|
|
} |
|
|
|
printf("Dein gewaehlter Buchstabe %c war ein Treffer!\n", x); |
|
|
|
counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(counter>0) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |