I need help figuring out how to make it so that when you guess, it let's you know you are wrong and tells if the right letter comes before or after the letter you guess. And if you are right it tells you that.
Also if you find any inconsistencies in my code so far tell me.
Code:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#define MAXGUESSES 6
void Instructions( );
int PlayGame(char answer);
char GetGuess( );
int CompareGuess(char guess, char answer);
int main()
{
//declare additional variables
char letter=0;
int gamesToPlay = 0;
int i = 0;
FILE *inp;
Instructions();
inp=fopen("guessLtrs.txt","r");
scanf(" %d",&gamesToPlay);
//get c letter
//open file
//get number of games to play
for(i=0;i<gamesToPlay;i++)
{
fscanf(inp," %c",&letter);
GetGuess( );
//get a letter from file
//Play one game
//check for win or lose
}
fclose(inp);
//close file
return 0;
}
//this function provides instructions to the user on how to play the game
void Instructions( )
{
printf("Welcome to Letter Guess\n");
printf("To begin you will enter the number of games you want to play(1 – 5 games)\n");
printf("You have 6 chances to guess each letter\n");
printf("Let's begin:\n\nHow many games would you like to play? (1 - 5):");
return;
}
//this function prompts the player to make a guess and returns that guess
//this function is called from inside the PlayGame( ) function described above
char GetGuess( )
{
char guess=0;
printf("Enter a guess:", guess);
scanf(" %c",&guess);
return guess;
}
//this function takes two arguments, the guess from the player and the answer from the file.
//It lets the user know if the guess comes alphabetically before or after the answer
//The function returns 1 if the guess matches the answer and returns a 0 if they do not match
int CompareGuess(char guess, char answer)
{
char value;
if (guess > answer)value=0;
else value=1;
printf("letter come before");
return 0;
}
//this function runs one game. It for checks either 6 incorrect guesses or correct guess.
//It returns a 0 if the game is over and the player did not guess the letter, otherwise it returns 1.
int PlayGame(char answer)
{
int numGuesses = 0;
while(numGuesses < MAXGUESSES)
{
//get guess function call
//compare guess function call
//update counter for number of guesses used
numGuesses = numGuesses +1;
}
}