I was just wondering if anyone would be able to clarify a syntax issue I am having. It is towards the bottom of my code in the CompareLetters function and is dealing with the first if statement. Why am I getting an expected '=' message on the == and an expected expression message after the closing parenthesis. I have absolutely no idea why it is doing that and every reference I go to has their if statements just like mine. If someone could help me out, I would really appreciate it. Thanks.
P.S. I know a whole lot of the rest of the code is badly messed up. I am in the middle of a project. I would be more than open to any addition help though :)
EDIT: Also, in the PlayGuess function, when I try to call on the CompareLetters function, it will not allow me to enter ANYTHING in the parameters. If anyone is willing to take a loot at that for me, I will be forever in your debt!
#include <stdio.h>
#include <ctype.h>
#define MAX_GUESSES 5
void Instructions();
int PlayGuess(char solution);
char GetLetter();
int CompareLetters(char guess, char solution);
int main ()
{
Instructions();
return 0;
}
void Instructions ()
{
printf("Hello, and welcome to the letter guessing game.\n");
printf("You will be allowed five guesses for up to four games, depending on how many you wish to play.\n");
printf("The goal is simple; just keep guessing different letters until \nyou choose the correct one.\n");
printf("After each guess, you will be informed if the solution is alphabetically behind or ahead of your guess.");
printf("If the correct letter is chosen, the game is over and you have won!\n");
printf("If you fail to choose the correct letter after your fifth try, you lose.\n");
printf("Okay, now lets begin.\n");
}
int PlayGuess(char solution)
{
int NumGuesses=0; int WinOrLose=0;
while (NumGuesses < MAX_GUESSES && WinOrLose==0);
{
GetLetter();
CompareLetters();
NumGuesses++;
}
}
char GetLetter()
{
printf("Please enter your letter guess: ");
char UserGuess;
scanf("%c", &UserGuess);
UserGuess = tolower(UserGuess);
return UserGuess;
}
int CompareLetters(char guess, char solution)
{
if(char guess == char solution)
{
return 1;
}
else
{
return 0;
}
}
Line 37: You're trying to call CompareLetters without specifying any arguments.
What are the exact errors are you're getting?
Edit: In PlayGuess, you need both solution and guess so you can pass them to Compare letters. Then you need to do something with the result returned by CompareLetters.