Sign in to follow this  

error with functions

This topic is 4861 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
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
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

This topic is 4861 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this