By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

error: expected identifier or ( before { token ??

P: 1
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
Feb 10 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 2,400
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.
Feb 10 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.