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