Solved

Error in performing link list

Posted on 2000-03-17
4
221 Views
Last Modified: 2010-04-02
I have a problem in compiling this source code , can someone help me to solve it. i'm using VC++6.

the source:


#include<iostream.h>


struct link
{
      int data;
      link* next;
};

class linklist
{
private:
      link* front;
public:
      linklist()
      {front = NULL;}
      void additem(int d);
      void display();
};

void linklist::additem(int d)
{
      link* newlink = new link;
      newlink->data = d;
      newlink->next = front;
      front=newlink;
}

 void linklist::display()
{
      link* current = front;
      while(current != NULL)
      {
            cout<<endl<<current->data;
            current=current->next;
      }
}


void main()
{

      linklist l1;

      l1.additem(20);
      l1.additem(50);

      l1.display();

}



the error:

Linking...
libcd.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/testlink.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

But when i compile with VC++ 5 it doesn't have any error.
0
Comment
Question by:eddyhalim
4 Comments
 
LVL 1

Accepted Solution

by:
loumf earned 20 total points
ID: 2630329
Create a new Console project and add this file to it.  Should compile fine.  Looks like you accidentally created a windows program project.
0
 
LVL 4

Expert Comment

by:wylliker
ID: 2630338
How did you set up your project?

You can't use main as your entry point unless you are using a Console App.

You need to create a new project.

Second, main() should be declared as:

int main( int argc, char *argv[]);




0
 
LVL 33

Expert Comment

by:hongjun
ID: 2630401
Try creating a Win32 Console Application.

It should work fine.

hongjun
0
 

Author Comment

by:eddyhalim
ID: 2643722
thanks for your all suggestion
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ - Convert a wString to char * 9 518
MSVCR80.dll crash 2 134
add elements to existing standard structure 2 96
Create a path if not exists 7 69
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now