Archived

This topic is now archived and is closed to further replies.

Function Calls

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

Recommended Posts

I am having trouble with functions. I get a linker error whenever I try to link this program. Could someone please tell me what the problem is, here i my source:
#include<iostream.h>

//----------------------------------------------------------------------------------------------

void DrawBar(int length)
{
const char mark=''*'';
for(int i=0; i<=length; i++)
cout<<mark;

cout<<endl;
}

//----------------------------------------------------------------------------------------------

int main()
{

cout<<"Hello";

return 0;

} 
The error I get is "fatal error LNK1120: 1 unresolved externals" Any help would be much appreciated

Share on other sites
quote:
Original post by bioagentX
The error I get is "fatal error LNK1120: 1 unresolved externals"
Any help would be much appreciated
It would be helpful if you would post the line above that message, which says which external it failed to resolve.

However, I''d guess that you try to compile this as a Win32 application which needs a WinMain() entry function. Otherwise, you should make console application.

Share on other sites
This is what is says above that message

"LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16"

any better?

Share on other sites
Switch to Windows Console application...it will work better

[edited by - Android_s on June 5, 2003 3:12:04 PM]

Share on other sites
How do you know when to use Win32 application or Windows console???

Share on other sites
Thanks a lot. What a stupid error on my part. I must have accidentally saved it as win32. Sorry for such a stupid question

Share on other sites
A win32 application is an application that uses graphics such as buttons, windows and toolbars. A console application uses nothing but a dos window, similar to the dos prompt.

[edited by - BioagentX on June 5, 2003 3:19:07 PM]

Share on other sites
quote:
Original post by MaximusPrime
How do you know when to use Win32 application or Windows console???
If you want a console application, ie. a program executed from the command line and no GUI, you use a console application, otherwise you use a Win32 application.

Share on other sites
Don't be confused though....

In VS .Net, in order to make a console application you first have to start a win32 project, and then select console application from the following options dialog.

...Be mindful, that's the case ONLY if you're using .Net. In VS 6, you can create a console application from the projects dialog box.

[edited by - tmoneyksu on June 5, 2003 11:56:56 PM]

Share on other sites
point of order, you can use consoles in a win32 program.

int WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
AllocateConsole();
Sleep(1000);
FreeConsole();
reutnrn 0;
}

Share on other sites
quote:
Original post by Anonymous Poster
point of order, you can use consoles in a win32 program.
On the contrary, you can use windows and all other stuff from a console application as well

Share on other sites
Are you using the namespace ''std''?

If not add the following code after the predirectives:
using namespace std;

Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"Do or do not. There is no try."
- Yoda

• Forum Statistics

• Total Topics
628702
• Total Posts
2984299

• 23
• 10
• 9
• 13
• 13