Why line 10 doesnt work??
if last letter is = hold...WEIRD
thanks for looking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
void guess_letter (char word_player[], int word_size, char underscore[],char letter_used[])
{
char guess, hold='\0';
char valid;
int x;
do{
while(hold == guess)
{
printf("Enter a guess letter: ");
scanf("%c%*c", &guess);
guess = tolower(guess);
printf("got letter %c\n",guess);
if(guess >= 'a' && guess <= 'z')
{
valid = 'y';
for (x=0; x < word_size; x++)
{
if(word_player[x] == guess)
underscore[x] = guess;
letter_used[x] = guess;
}
printf("Now the word is %s\n",underscore);
printf("Letters used %s\n",letter_used);
}
else
{
valid = 'n';
printf("Invalid Input. Enter a letter.\n\n");
}
}
hold = guess;
printf("%c%", hold);
}while(valid != 'y');
return;
}
|
Last edited on
You are comparing guess to hold at line 10, but guess hasn't been initialized to anything yet.
First time through line 10, guess is uninitialized so the results of the while condition are indeterminate.