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): error C2181: illegal else without matching if
(102): error C2059: syntax error : 'type'

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define WIN 'W' 
#define LOSE 'L'
#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);

        }while (answer == 'y' || answer == 'Y');
    }

        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();
    {

        printf("Hello, and Welcome to Letter Guess Game:\n");
        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");

        {
        }
    }
    char answer;    
         answer = Play(); 
    if (answer == 'W' ) 
        { 
        printf("Wow! You guessed it!");
        printf("Congratulations! You win!");
        printf("Goodbye for now!:\n");

        return 0; 
        } 
    else if (answer == 'L') 
        { 
        printf("You Lose!SORRY"); 
        return -1; 
        } 
    else 
        { 
        printf("You entered invalid char"); 
        } 
        } 
    char Play () 
        { 
    int guess = 0; 
    char entered_char; 
    char fixed_char; 

        fixed_char = getLetter(); 
    while (guess < MAX_GUESSES) 
    { 
        printf("Enter your choice of letter\n"); 
        scanf("%c",&entered_char); 

    if (entered_char == 'Y') ||(entered_char == 'y') 
        printf("INSTRUCTIONS: You get %d chances to enter your choice, Please begin",((MAX_GUESSES - 1) - guess)); 

    else if (entered_char == fixed_char) 
    return 'W'; 

    else if (char(entered_char) == 0) 
        return -1; 

        guess++; 
    } 
        printf("The fixed char was %c ",fixed_char); 
        return 'L'; 
    } 
    char getLetter() 
    { 
        srand((unsigned int) time(NULL)); 
        return ((rand() % 26) + 'a'); 
} 

Line 53, remove the semi-colon from the end of that line. Remove lines 61 and 62. Line 94, put a space before the % in the scanf-- scanf(" %c", &entered_char);

Line 96, you need to surround both logical arguments in your if statement, with parentheseis:

if((argument1) || (argument2))

Line 102, delete the word char in that line. The variable is already declared in your program, you can't /shouldn't re-declare it.

You should be re-compiling your program frequently, to catch any syntax errors before they cause zillions of other errors during compilation.

Edited 3 Years Ago by Adak

This article has been dead for over six months. Start a new discussion instead.