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.

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

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
point of order, you can use consoles in a win32 program.

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

Share this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites