Pelles C forum
C language => Beginner questions => Topic started by: AMD on October 02, 2011, 12:31:31 PM
-
Please help i am trying to test this program after comiled it successfully.
here is my code:
#include <stdio.h>
int radius, area;
main()
{
printf( "Enter radius (i.e. 10): " );
scanf ( "%d", &radius );
area = (int) (3.14159 * radius * radius);
printf( "\n\nArea = %d\n", area );
return 0;
}
During compiling i get the following error:
Building QTwo.obj.
C:\Users\AMD\Documents\Road to Lite Hacker\C Language\Day 1\Exercises\Q2\QTwo.c(5): warning #2099: Missing type specifier; assuming 'int'.
Done.
When i try to build .exe file i receive the following error:
Building Q2.exe.
POLINK: error: Unresolved external symbol 'WinMain'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.
i have no idea where this error is coming from. any help is really appriciated here.
Thank you in advance
-
Hi AMD,
Welcome to the forum.
The type specifier for the main function is missing.
Add int to line 5 :
int main()
POLINK: error: Unresolved external symbol 'WinMain'.
Are you sure that your project is configured to be built as console application? It looks like that you are trying to make a GUI application.
-
Thank you Vortex
for your magic answer.
It worked after adding the int in from of Main()
and you were right to guess i wasn't choosing consile but now i corrected it and everything worked fine.
Thank you again
-
@amd ... Pelles C comes with a truly excellent help file. You may want to spend just a few minutes looking around in it. There's a ton of helpful hints and even a "your first program" tutorial in there, to get you started. Also be sure to look around in the IDE... click on stuff, right click on stuff... you'll find a lot of really helpful stuff that way...
On the main() thing... There are 2 generally preferred forms for the main function...
int main (void)
{
// your code here
return 0;
}
for when you are not using command line arguments, and...
int main (int argc, char *argv[])
{
// your code here
return 0;
}
when you want to read in data from the command line.