RidaSana
RidaSana

Reputation: 563

linker error problem

Program:

#include<iostream>


using namespace std;

int main()

{

    int a[5] = {4,5,9,1,2};

    int i,j,temp;
    cout<<"Assending sorting: "<<endl;

    for(i=1; i<5; i++)
    {
       temp = a[i];
       if(a[i]<a[i-1])
       {
           temp = a[i-1];
           a[i-1] = a[i];
          a[i] = temp;
       }
    }

}

Error:

error LNK2005: _main already defined in assen test.obj  
C:\Program Files\Microsoft Visual Studio 10.0\my Project\sorting\binary
search\main.obj

error LNK1169: one or more multiply defined symbols found   
C:\Program Files\Microsoft Visual Studio 10.0\my Project\sorting\Debug\binary 
search.exe

From my point of view, the program should work OK, but i don't understand the linker error. Can anyone help me out?

Thanks

Upvotes: 0

Views: 296

Answers (1)

Constantinius
Constantinius

Reputation: 35039

As far as I can see, you seem to have declared two functions with the name main in your code, possibly in another .c/.cpp file.

Upvotes: 3

Related Questions