Guessing game help?

this is the assignment I need some help with.I have posted what i have written so far for this assignment and am not sure what steps to take next, or if i have properly coded so far.

I'm trying to get my program to work but it won't compile i keep getting these errors below. when I try to build a solution. Can someone help me to fix these errors? I know that it is probably something simple, however after a few hours I have run out of ideas.

The guidelines for the assignment can be found here: http://pastebin.com/WbJZnT4h

the piece of code that is giving me the error is:


(53): error C2143: syntax error : missing ';' before 'type'
(64): error C2143: syntax error : missing ';' before 'type'
(96): error C2143: syntax error : missing ';' before '||'
(99): C2181: illegal else without matching if
(102): error C2059: syntax error : 'type'

all error is in bold


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  
#include<stdio.h>
#include<stdlib.h>
#include <time.h> 
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#define MAX_GUESSES 6


	// This function displays game instructions, and returns nothing.
void Instructions();

	// This function plays one game, and returns "W" if the player wins
        // or "L" if the player runs out of guesses. 
char Play();

	//this function prompts the player to make a guess and returns that guess

char getLetter();

	//The function returns 1 if the guess matches the solution and returns a 0 if they do not match
char guess;

// This function returns a random letter between "A" and "Z 
char getAnswer();

int main()
{
	char answer;

		
	Instructions();
	//1. Greet the user and ask if they would like to play a guessing game.
		printf("\nHello there! Would like to play a guessing game?Enter Y or N: \n");
		scanf(" %c", &answer);

		if(answer == 'y' || answer == 'Y')
{

		do{
		char Play();
		printf("\nDo you want to play again? Y or N: \n");
		scanf(" %c", &answer);

		[b][b]}while (answer == 'y' || answer == 'Y');[/b][/b]
}

		printf("GoodBye!");
		return -1;
}

	//1. Greet the user and ask if they would like to play a guessing game.
	//this function provides instructions to the user on how to play the game
	void Instructions()
{
		[b]printf("Hello, and Welcome to Letter Guess Game:\n");[/b]
		printf("I have a capital letter in mind. You have 6 chances to guess which letter I am thinking. I will let you know if you are too high or too low:\n" );
		printf("After each guess, you will be informed if your guess is too high or too low. Good luck!:\n");
		printf("Okay, now lets begin:\n");
		}
	

	//player defined guesses.


char getLetter()

{		
int i = 0;
i = rand() % 27;
i = i + 65;
char x = convert (char)i;
return x;// this will be a random letter to be guess by the user. 
}

char Play (char W, char L)
{
	
char Letter = getLetter(); // will contain the random letter
int count = 0; // keep track of the count
{	

while(count != 6)
{
	printf("Guess the word? ");


[b]	[b]if(Letter > guess)[/b][/b]
{
	printf("I am sorry but your guess is too LOW.");
	count<6;
	}
	else if (Letter < guess)
[b][b][b]{
	printf(" I am sorry but your guess is too HIGH.");
	count++; [/b][/b]
	}[/b]
	else 
{
	printf("Wow! You guessed it!");
	printf("Congratulations! You win!");
	printf("Goodbye for now!:\n");

	return W;
	} 
	// end while
	count=0;
	}	

	return L;

}
Last edited on
line 72 what is the convert supposed to be doing? Are you trying to cast? If so remove the convert and it should work fine. Assuming you are turning an ascii int to a character.

line 91 does nothing. It checks if that is true or false if it is true it does nothing if it is false it does nothing.

Also in your last function ( starting on line 76 ) I believe you are missing a closing brace. It is really hard to tell though since your indentation is completely off.

http://indentcode.net/

Yep you're definitely missing a closing brace.
Lines 5 and 6.
Hmm?
Topic archived. No new replies allowed.