Jump to content
  • Advertisement
Sign in to follow this  
Sir Asksalot

error with functions

This topic is 5144 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello.Here's my problem.I run my programs under msvc++ 6.0 and all goes fine.That is until i try to use functions then i get an error.I dont understand where it blocks.I dont think i made mystakes.Below you will find an example of code that wont work for me ( yes its very simple!) and what i get in my build window. code: #include<stdio.h> void comeon(int); main() { int a; a=20; comeon(a); return 0; } void comeon(int h) { printf("%d",h); } the build window: Deleting intermediate files and output files for project 'a - Win32 Debug'. --------------------Configuration: a - Win32 Debug-------------------- Compiling... p.cpp Linking... LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/a.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. a.exe - 2 error(s), 0 warning(s) SEE WHAT YOU CAN MAKE OF THIS.THANKS

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster

One problem you've got is that you don't have the variable type main is returning. In your case, you would need:

int main()

From the sound of the error, when you created your project, you created a Win32 application. When you do that, you need to have a WinMain function (the main entry point for these types of applications). You want to create a console application. This will allow you to use the standard main() function as the program entry point.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster

One problem you've got is that you don't have the variable type main is returning. In your case, you would need:

int main()
I believe in C++, if a return type is not specified, then the default return type is int.

Share this post


Link to post
Share on other sites
Yep thnaks,its indeed because i wasnt using a console application.For the main part,the int isnt necessary.Like tronk3k said,int is assumed.Thanks for everything.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tron3k
I believe in C++, if a return type is not specified, then the default return type is int.


Ahh!!

Quote:
Original post by Sir Asksalot
For the main part,the int isnt necessary.Like tronk3k said,int is assumed.Thanks for everything.


Ahhhhhh!!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!