Microsoft Visual Studio 2010出现LNK1120问题
我用的是Micro Visual Studio 2010 ,编译时出现MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup1>D:\Program Files\Microsoft Visual Studio 10.0\myproject\test6gai\Debug\test6gai.exe : fatal error LNK1120: 1 unresolved externals
请问高手如何解决?程序应该不会错,是从C++ Primer上照抄下来的。有人说改project->setting->link.可是2010没有这个选项啊。
#include<iostream>
#include<vector>
using namespace std;
int mian()
{
int ival;
vector<int> ivec;
cout<<"enter numbers(Ctrl+z to end)"<<endl;
while(cin>>ival)
{
ivec.push_back(ival);
}
if(ivec.size()==0)
{
cout<<"no element"<<endl;
return -1;
}
cout<<"sum of each pair of adjacent elements in the vector:"<<endl;
vector<int>::size_type cnt=0;
for(vector<int>::iterator iter=ivec.begin();iter<ivec.end()-1;iter=iter+2)
{
cout<<*iter+*(iter+1)<<endl;
++cnt;
if(cnt%6==0)
cout<<endl;
}
if(ivec.size()%2!=0)
{
cout<<"最后一个元素没参加计算,这个值为"<<*(ivec.end()-1)<<endl;
}
return 0;
}