Im supposed to make a little game in which you're supposed to guess a letter in 6 tries. It reads the letters from a text file. I get a bunch of errors and dont really know what to do. Any suggestions?
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#define MAXGUESSES 6
//this function provides instructions to the user on how to play the game
void Instructions( );
//this function runs one entire game. It for checks either 6 incorrect guesses or a correct guess.
//It returns a 0 if the game is over and the player did not guess the letter, otherwise it returns 1.
int PlayGuess(char solution);
//this function prompts the player to make a guess and returns that guess
//this function is called from inside the PlayGuess( ) function described above
char GetLetter( );
//this function takes two arguments, the guess from the player
//and the solution letter 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 solution and returns a 0 if they do not match
int CompareLetters(char guess, char solution);
int main()
{
FILE* infile;
FILE* outfile;
char guess = 0;
char solution = 0;
char c = solution;
int gamesToPlay = 0,
i = 0;
Instructions();
infile = fopen(" .text","r");
scanf(" %d", &gamesToPlay);
for(i=0;i<gamesToPlay;i++)
{
fscanf(infile," %c", &guess);
PlayGuess(char (solution));
CompareLetters(char (guess), char (solution));
}
fclose(infile);
return 0;
}
//Function definitions
//this function provides instructions to the user on how to play the game
void Instructions( )
{
printf("Welcome to my mini game\n");
printf("Guess the right letter in order to win the game\n");
printf("You will have 6 chances to guess the letter\n");
printf("Let's begin, good luck\n");
}
//this function runs one entire game. It for checks either 6 incorrect guesses or a correct guess.
//It returns a 0 if the game is over and the player did not guess the letter, otherwise it returns 1.
int PlayGuess(char solution)
{
int numGuesses = 0;
int MAXGUESSES = 6;
while(numGuesses < MAXGUESSES)
{
GetLetter( );
CompareLetters(char guess, char solution);
if(numGuesses > MAXGUESSES)
{
printf("You weren't able to guess the letter in 6 tries. Sorry but you LOSE!\n");
}
numGuesses = numGuesses +1;
}
}
//this function prompts the player to make a guess and returns that guess
//this function is called from inside the PlayGuess( ) function described above
char GetLetter( )
{
char guess = 0;
printf("What is your guess?\n");
scanf(" %c", &guess);
}
//this function takes two arguments, the guess from the player
//and the solution letter 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 solution and returns a 0 if they do not match
int CompareLetters(char guess, char solution)
{
char guess = 0;
char solution = 0;
if (guess == solution)
{
printf("congratulations! You won!");
return 1;
}
else if(guess < solution)
{
printf("Sorry that's incorrect. The letter is alphabetically higher. Please try again.\n");
GetLetter( );
return 0;
}
else if(guess > solution)
{
printf("Sorry that's incorrect. The letter is alphabetically lower. Please try again.\n");
GetLetter( );
return 0;
}
}