undefined reference to `WinMain@16' in VS Code

29 Views Asked by At

I was running a simple linear search program on VS Code using the MinGW compiler for cpp,

Here is the code:

#include<iostream>
using namespace std;



int main()
{
int a[10]={01,56,38,29,50,45,38,92,67,53};
int item,loc=NULL;
cout<<"Enter the number you want to enter: ";
cin>>item;
int i=9;
while (i)
{
    if(a[i]==item)
    {
        loc=i;
        i=0;
    }
    else
    {
        i--;
    }

}
if(loc!=NULL)
{
    cout<<"The element wa found on the location "<<loc<<endl;
}
else{
    cout<<"The element was not present in the array";
}

return 0;
}

And here is the error that im getting:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status

I'm really screwed up with this error as I don't get this error for other files but I get for the file on which I'm running this code. Please help me fix this error.

0

There are 0 best solutions below