Well, I'm making a hangman game. Can you help me on how I can replace the word with asterisks? Thanks
Well, I'm making a hangman game. Can you help me on how I can replace the word with asterisks? Thanks
Write all of it except for the substitution part. Get it so you can enter letters and find out if they are in the word you are looking for, once you have that done, it should be pretty easy to substitute out letters.
Quzah.
Hope is the first step on the road to disappointment.
What is the substitution part?
Fill an array with as many * as there are letters in the word. When a letter is matched, go to that spot and replace the * with the letter.
Quzah.
Hope is the first step on the road to disappointment.
Oh! Thanks But I've put this in my code, is this correct?
k=strlen(words[j]);
for(l=0;l<k;l++){
printf("*");
}
printf("\n");
where words[j] is the word the user will guess. Did I replace the word with asterisks correctly?
You need to use code tags if you post code. All you are doing is showing *, not actually placing them in an array anywhere. While I suppose you could get by with your way, it would be more cumbersome than just putting them in an array.
Quzah.
Hope is the first step on the road to disappointment.
Hmm. I've found this:
but it doesn't seem to work on my codej = strlen(name);
for(; k<j ; k++)
{
guess[k]='*';
}
Copy 7 * into 'guess'.Code:char word[] = "secret"; char guess[ BUFSIZ ] = {0};
Every time there is a letter guessed, run through each character in 'word', and see if it matches. If it does, replace that * with the guessed letter.
Quzah.
Hope is the first step on the road to disappointment.
Thanks!)