I am trying to get my program to run in Visual Studio 2012, but it won't. I keep receiving errors on my brackets, such as missing function header or 'expected a declaration'. I knew they were messed up from the start, but I just can't seem to get it right. Could someone please help me with this and explain where I messed up? Thank you very much! Here is my code:

#include <stdio.h>
#define MAXGUESSES 5

int SingleGame(char file_letter);

int main()
    //declare additional variables
int PlayGames = 4,
i = 0;
FILE * infile;
char letter;
    //display instructions
    printf("Welcome to the Letter Guessing Game!\n");
    printf("You will enter the number of games that you want to play, which is 1-4 games\n");
    printf("You have 5 chances to guess each letter\n");
    printf("Let's begin!\n");

    //open file
    infile = fopen("lettersin.txt", "r");

    //get number of games to play
    printf("How many games would you like to play?(1-4)\n");
    scanf("%d", &PlayGames);

        //get a letter from file
        fscanf(infile, " %c", &letter);

        //Play one game
        printf("Let's play a game %d\n", i);

        //check for win or lose
        SingleGame (letter);

    //close file
    return 0;
int SingleGame(char file_letter);

//Function definitions
    int numGuesses = 0;
    while(numGuesses < MAXGUESSES);
    char RetrieveGuess = 0;
    int PlayGames = 0;

        printf("Enter a guess\n");
        scanf("%c" , &RetrieveGuess);
        if(file_letter == RetrieveGuess);
            printf("You guessed it!\n");
                printf("The letter you are trying to guess comes before:%d\n",RetrieveGuess);

            else if(file_letter<RetrieveGuess);
                printf("The letter you are trying to guess comes after:%d\n", RetrieveGuess);

            numGuesses = numGuesses +1;

2 Years
Discussion Span
Last Post by rubberman

You're putting semi-colons(;) where they don't belong. They are needed in the function prototype but not in the function declaration. if statements don't take semi-colons either.


What tinstaafl said. Look at the function definition on line 43: int SingleGame(char file_letter);

You want to remove the semicolon as that makes the compiler pretty much ignore the rest of the code.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.