error: expected identifier or â(â before â{â token ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bals3239
    New Member
    • Feb 2010
    • 1

    error: expected identifier or â(â before â{â token ??

    I am using a program called putty to write basic programs in C/ C++ for an introduction to computer programming class. I am very new at programming and am just getting started writing very simple programs. When I try to compile my programs, I receive an error message saying

    error: expected identifier or â(â before â{â token

    and am directed to the line in the program where the program actually starts, the beginning bracket {
    this is the only character on the line, and I have received this error message trying to compile multiple programs all at the the same line where the left bracket is placed after int main is established. Any ideas on how I could fix this problem and make my programs able to compile would be fantastic, thank you
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Look at the lines preceding the definition of your main function.
    • Are any of them missing the terminating semicolon?
    • Are parentheses and braces balanced?
    • Ask the same questions of any header files that are included prior to the definition of main.


    Look at the definition of your main function.
    • Did you balance the parentheses that enclose the parameter list?
    • There should not be a semicolon between the parenthesis that closes the parameter list and the brace that starts the body of the function.


    By the way, you do not want to provide a prototype for the main function.

    Comment

    Working...