Why am I getting an "Expected Identifier" error?

Simple C program problem. Error: Expected Identifier or '(' before '{' token?

  • Hi ive just started to learn about C and im using the compiler Codeblocks, my first program is this simple one shown below. However when i compile it there is an error. "Error: Expected Identifier or '(' before '{' token" what does this mean and how can i fix it? its driving me crazy, i cant find anything online and the fact that i cant get a simple program to work it offputting. #include <stdio.h> #define KMS_PER_MILE 1.609 int main(void); { double miles, kms; printf("enter the distance in miles> "); scanf("%lf", &miles); kms = KMS_PER_MILE * miles; printf("that equals %f kilometer./n, kms"); return (0); } so what is the issue here? it says the problem on line 5 where i use { however i have no idea what i did wrong. thanks hope you can help

  • Answer:

    Get rid of the semi-colon after int main(void); = int main(void) { .... return 0; }

tbshmkr at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

You should not put ';' , when you define a function. Remove ';' from int 'main(void);'. Hope this will solve the issue. :)

anukkutt

You should not put ';' , when you define a function. Remove ';' from int 'main(void);'. Hope this will solve the issue. :)

anukkutt

Get rid of the semi-colon after int main(void); = int main(void) { .... return 0; }

tbshmkr

remove ; in the main line

James Bond

This Site Might Help You. RE: Simple C program problem. Error: Expected Identifier or &#39;(&#39; before &#39;{&#39; token? Hi ive just started to learn about C and im using the compiler Codeblocks, my first program is this simple one shown below. However when i compile it there is an error. &quot;Error: Expected Identifier or &#39;(&#39; before &#39;{&#39; token&quot; what does this mean and how can i fix it?...

Kilian

You don't declare the same variable "int a" was set with inside the function when you're calling it from "main", a different function. Remove "int a" and put a value instead, or another variable.

Tammy

remove ; in the main line

James Bond

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.