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
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 '(' 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?...
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:
- How to solve Identifier Undefined error?Best solution by e2e.ti.com
- How Can I use .net dll in C program?Best solution by Stack Overflow
- How to run an executable from within a c program?Best solution by Stack Overflow
- How to create a simple counter program?Best solution by Stack Overflow
- Can anyone help me with this C++ program?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.