I have this assignment where the user has six guesses for the correct letter out of 1 to 4 games. I only have one error that won't let me pass my build and I can't seem to figure out how to fix it. Can anyone help me figure out what i need to do to complie my code right. I marked where my error occurs.
¬
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#define MAXGUESSES 6
int PlayGuess(char solution);
int main()
{
//variable declarations
int gamesToPlay = 0;
int i = 0;
FILE* infile;
char ans;
//intro
printf("Greeting to the Letter Guess!\n");
printf("First enter the number of games you wish to play from 1 to 4 games\n");
printf("Be warned there is a max of 6 chances to guess each letter\n");
printf("Now lets start the game:\n\n");
//opening the file
infile = fopen("inputLetter.txt", "r");
//getting the number of games to play
printf("How many games do you want to play (1-4)");
scanf("%d",& gamesToPlay);
for(i=0;i<=gamesToPlay;i++)
{
//get a letter from file
fscanf(infile," %c",&ans);
//playing game
printf("Let's play game %d\n", i);
//check for win or lose
PlayGuess (ans);
}
//closing file
fclose(infile);
return 0;
}
int PlayGuess(char solution);
{
int numGuesses = 0;
char getguess = 0;
int gamesToPlay = 0;
while(numGuesses < MAXGUESSES)
{
printf("Enter a guess\n");
scanf("%c", &getguess);
if(solution==getguess)
{
printf("Good job, you got it!\n");
}
else
{
if(solution>getguess)
{
printf("the letter you are trying to guess comes before:%d\n", getguess);
}
else if(solution<getguess)
{
printf("the letter you are trying to guess comes after:%d\n", getguess);
}
}
numGuesses = numGuesses +1;
}
}
¬