- #1
denZer
- 17
- 0
I'm well aware of all the Hangman codes that are out there given, but I feel that I will get a better understanding of this project if I did it myself with some help.
My main problem is knowing how to compare one character of array from a string text file. The text file consist of a whole word, but the user must guess each character right. From my main function, this is what I have:
For the fscanf, I don't know how to have it compare one character array at a time because it'll compare the whole words rather than one by one.
My main problem is knowing how to compare one character of array from a string text file. The text file consist of a whole word, but the user must guess each character right. From my main function, this is what I have:
Code:
int main ()
{
//variable that stands for the amount of guess from user
int TotalGuess;
int i;
int MaxGuesses;
MaxGuesses=6;
//guesses of user starts from 0
TotalGuess=0;
//variable that stands for the guess of the user
char UserGuess;
char answer;
FILE *inp;
char filestrings[SIZE];
//number of game always start at 0 and will be incremented by 1 when user plays more
Instructions();
inp=fopen("words.txt", "r");
for(i=0;i<MaxGuesses;i++)
{
//getting a letter from file
fscanf(inp, " %s", filestrings);
char UserGuess();
}
}
For the fscanf, I don't know how to have it compare one character array at a time because it'll compare the whole words rather than one by one.
Last edited: