link 错误求救
vc6.0环境。
代码为
#include <iostream>
#include <string>
#include <list>
using namespace std;
static list <int> m_ForbidChannelList;
list <int> getIntTagContents (string src, string startTag, string endTag)
{
list <int> contentList;
string::size_type posStartTag, posEndTag;
string::size_type posCurrent = 0;
for(;;)
{
posStartTag = src.find(startTag, posCurrent);
posEndTag = src.find(endTag, posCurrent);
if( posStartTag == string::npos || posEndTag == string::npos )
{
break;
}
else
{
int content = atoi(src.substr(posStartTag+startTag.length(), posEndTag-posStartTag-startTag.length()).c_str());
contentList.push_back(content);
posCurrent = posEndTag + endTag.length();
}
}
return contentList;
}
bool IsForbidChannel(int nChannel)
{
list <int> ::iterator itrList;
itrList = find (m_ForbidChannelList.begin(), m_ForbidChannelList.end(), nChannel);
if (itrList == m_ForbidChannelList.end())
{
return false;
}
else
{
return true;
}
}
void main()
{
string sForbidChannel = " <ForbidChannel> 109 </ForbidChannel> <ForbidChannel> 111 </ForbidChannel> ";
cout < < "Get forbid channel " < <sForbidChannel < <endl;
m_ForbidChannelList = getIntTagContents(sForbidChannel, " <ForbidChannel> ", " </ForbidChannel> ");
int i;
for(i=0;i <=100;i++)
{
if (IsForbidChannel (i))
{
cout < < "Skip forbid channel " < <i < <endl;
continue;
}
}
}
错误提示:
--------------------Configuration: stl - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/stl.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
stl.exe - 2 error(s), 0 warning(s)
找了半天还是没找出那里错了啊
郁闷啊~~~解决掉就结分~~
[解决办法]
加头文件#include <algorithm> 调试正确
[解决办法]
添加#include <algorithm> 编译通过
win2k+vc6
可能是你的VC设置有问题吧
看看tools-> options-> Directories里面路径是否正确~
[解决办法]
我也试了,没有问题啊
建议重新建控制台工程,把代码copy过去
不行就有可能像Kenmark说的是是路径问题
[解决办法]
应该是编译器参数设置的问题
方案一:去除_ATL_MIN_CRT这个预处理符号
方案二:打开stdafx.h,注释掉#include <atlimpl.cpp> 这句话
如果还不成,可否发一份到位的邮箱里?int2e@126.com