Code:
<stdio.h>
#include <ctype.h>
#define MAX_GUESSES 6
//function prototypes
int main()
{
FILE* infile;
int i;
int numberofGames;
char ans;
char getguess;
int compareguess(char guess, char ans);
printf("Please enter the no of games you want to play");
scanf("%d",& numberofGames);
//variable declarations
//prompt + get numgames
//display instructions on how to play the game
printf("Enter an letter in the range a to z\n");
printf("I will try to guess your letter with in 6 guesses\n");
printf("If you can guess my letter in 6 guesses, You Win!\n");
printf("Would you like to play?\n");
printf("Press 'Y' to play, or 'N' to quit\n");
printf("Char Playgame\n");
//connect to the file
infile = fopen("letters.txt", "r");
return
0;
}
for
(i=1; i<=numberofgames; i++)
{
//print current game (value of i)
//get letter to guess from fscanf
scanf(infile," %c",&ans);
//printf to check the letters from file
printf("%c",&ans);
//call the play function to play a game
numgames=playGame (ans);
//it will return a 1 if the user wins and a 0 if the user took more than 6 guesses
//condition here to print win or lose
numgame==0'lose';numgame==1'win';
}
void Instructions()
{
//instructions on how to play game
}
intplayGame (char ans);
{
char guess;("numberOfGuess=0"), ("winOrLose=0");
//call the play function to play a game
numberOfGames=playGame (ans);
//it will return a 1 if the user wins and a 0 if the user took more than 6 guesses
//condition here to print win or lose
numberOfGames==0("lose");
numberOfGames==1("win");
return 0;
}
chargetGuess()
{
//get the users' guess
userGuess = toLower(userGuess);
//change to lower case
//return the users' guess
return 0;
}
intcompareGuess(char guess, char ans)
{
//compare the guess and the answer
compareGuess and ans;
//return a 1 if they are the same
return a 1 if ("both are the same");
//print a message based on before or after alphabetically
printf("message based on before or after alphabetically",&ans);
//return a 0 if the guess and answer are not the same
return a 0 if ("the guess and answer are not the same");
return 0;}