Hangman Game - Storing variables and such
Nov 11, 2011 at 3:02am UTC
I will have to eventually use an array called "guessed_letters" (which a character is added with each guess) but in the mean time, I am using char user_guesses to store the temporary chars, but how can I add it to the array of guessed_letter later on?
main function looks like this:
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
{
int i;
int position_of_letter;
FILE *inp;
char word_to_be_guessed[SIZE];
char word_in_progress[SIZE];
char guessed_letter[SIZE];
char length;
char user_guesses;
//guesses of user starts from 0
i=0;
inp=fopen("words.txt" , "r" );
fscanf(inp," %s" , word_to_be_guessed);
length=strlen(word_to_be_guessed);
Instructions();
MysteriousWord(word_to_be_guessed,word_in_progress);
do
{
user_guesses=GetGuess();
{
position_of_letter=CheckLetter(user_guesses,word_to_be_guessed);
if (position_of_letter<0)
{
printf("The letter you guessed is incorrect, please try again: \n" );
MysteriousWordUnveiled(word_to_be_guessed,word_in_progress,position_of_letter);
}
}
}
while (position_of_letter<0);
{
printf("You guessed one right!\n" );
MysteriousWordUnveiled(word_to_be_guessed,word_in_progress,position_of_letter);
}
}
Would it be easier to just create a user defined function?
Topic archived. No new replies allowed.