need help using arrays ( simple hangman game)
heeey guys I need your help to create a code. I totally forget how to use arrays
and I need to use two arrays for a hangman game one holds the characters of the secret word
and the other one holds the characters of the current status.
for example : if the secret word is " book"
and the user guessed "o" "this is the 1st try"
the output should look like this "-oo-"
however when the user guess another letter let's say G "2nd try"
the output should still be "-oo-"
also, the user have only 8 tries
anyone can help me
that what I got so far
and I know it's not right at all :(
Code:
#include <stdio.h>
int main()
{
char word[] = {'b','o','k'};
char j;
int i;
for(i=1; i<=8; i++)
{
printf("Guess a letter: ");
scanf("%c", &j);
if(j == 'b')
printf("b---");
else if(j == 'o')
printf("-oo-");
else if(j == 'k')
printf("---k");
else
printf("Guess again");
}
return(0);
}