erros of undeclared variables and missing ;

October 2, 2011 at 17:10:43
Specs: Windows 7
Guesses letter game

#define _CRT_SECURE_NO_DEPRECATE
#include <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
//file pointer declaration
//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
fscanf(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';

int playgame (char ans);
{
char guess;
numberofguess=0, win or lose=0;
//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';
}
return 0;
}

char GetGuess()
{
//get the users' guess
userguess = tolower(userguess);//change to lower case
//return the users' guess
return 0;
}

int compareguess(char guess, char ans)
{
//compare the guess and the answer
compare guess 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;
}


See More: erros of undeclared variables and missing ;

Report •

#1
October 3, 2011 at 00:23:15
The compiler should tell you on which lines the errors occur. They should be (and are) fairly obvious. There are quite a few errors in this program so fix them one-by-one until the compiler complains no longer. If you have real problems with a particular error then post back with the error message. But first make the effort to track down the errors yourself; this is the only way that you will learn.

Learn how to use the information that the compiler provides; most will give you the exact location of an error.


Report •

#2
October 3, 2011 at 00:29:09
//Guesses letter game

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <ctype.h>

#define MAX_GUESSES 6

//function prototypes
	int i;
	int numberofgames;
	char ans;
	char getguess;
	int compareguess(char guess, char ans);

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
	//file pointer declaration	
	//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");

	for(i=1; i<=numberofgames; i++)
	{
		//print current game (value of i)
		//get letter to guess from fscanf
		fscanf(infile," %c",&ans);
		//printf to check the letters from file
		printf("%c",&ans);
	return 0;
	}

	int playgame (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;
}


Report •

#3
October 3, 2011 at 00:32:37
//Guesses letter game

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <ctype.h>

#define MAX_GUESSES 6

//function prototypes
int i;
int numberofgames;
char ans;
char getguess;
int compareguess(char guess, char ans);

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
//file pointer declaration
//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");

for(i=1; i<=numberofgames; i++)
{
//print current game (value of i)
//get letter to guess from fscanf
fscanf(infile," %c",&ans);
//printf to check the letters from file
printf("%c",&ans);
return 0;
}

int playgame (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;
}

errors:
(50): error C2143: syntax error : missing ';' before 'type'
(55): warning C4013: 'playgame' undefined; assuming extern returning int
(58): error C2064: term does not evaluate to a function taking 305 arguments
(59): error C2064: term does not evaluate to a function taking 305 arguments
(63): fatal error C1075: end of file found before the left brace '{' at 'c:\users\addysonjones\documents\visual studio 2010\projects\guessletters\guess.c(17)' was matched


Report •

Related Solutions

#4
October 3, 2011 at 01:34:28
Well, let's look at the first error. It says that something is wrong on line 50

int playgame (char ans);

I suspect that you are actually trying to define a function "playgame" in this line. If that is the case then the ";" shouldn't be there. Secondly, you are declaring the function within the "main" function. Now I'm sure that someone will correct me if I am wrong, but I don't believe that C allows this (although some languages do).

Correct those errors and try again. (There is another error - you have more opening braces than closing ones - that should be corrected in the process.) You will still get errors - for example lines 58 and 59 are not valid C constructs, but attack them one-by-one. Think about what each line of code is meant to do and the errors should be fairly obvious.


Report •

Ask Question