Hi there. i got stuck with this code. i can't get the right code for the loop to put the letter into the blank. Can anyone help me here.
thanks a lot.
Code:
printf("enter a word to guess: \n"); do{
c=getch();
switch(c)
{
case '\r':
break;
case '\b':
printf("\b \b");
if(x>0) --x;
break;
default:
printf("%c", '*');
word[x++]=c;
break;
}
}while(c != '\r');
word[x]='\0';
system("cls");
length=strlen(word);
undscr[x]='_';
printf("\n\nthe word to guess is: ");
for(undrscr=0;undrscr!=length;undrscr++)
{
printf(" %c", undscr[x]);
}
printf("\n\nguess a letter: ");
scanf("%s", &guess_letter[x]);