main()函数最后大括号处抛出异常???:unhandled exception in **.exe:Access Violation

risefei_sarah 2007-05-14 04:21:12
调试时,在main()函数最后大括号处,return 0;也执行完了,出现异常:unhandled exception in **.exe:Access Violation

然后调试进入(Microsoft Visual Studio\VC98\Include\XTREE):iterator begin()
{return (iterator(_Lmost())); }

可是我看XTREE只是显示一文件,并没有显示为XTREE.h形式啊?

debug显示:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shimeng.dll', no matching symbolic information found.
First-chance exception in beyes.exe: 0xC0000005: Access Violation.
...全文
1458 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
庄鱼 2007-05-15
  • 打赏
  • 举报
回复
看看头文件,是不是在模板定义时丢了括号或分号
yutaooo 2007-05-15
  • 打赏
  • 举报
回复
mark 一下
risefei_sarah 2007-05-15
  • 打赏
  • 举报
回复
是全局变量重复定义的事,可是vc6没有提示错误,不过有警告。
用extern解决掉了。
谢谢大家
risefei_sarah 2007-05-14
  • 打赏
  • 举报
回复
那怎样处理呢?

是越界了:调试指向iterator begin();

map::begin
const_iterator begin() const;
iterator begin();
The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
lb_hit 2007-05-14
  • 打赏
  • 举报
回复
估计是内存错误,比如越界什么的,然后在析构的时候出错了。
risefei_sarah 2007-05-14
  • 打赏
  • 举报
回复
如果map,inser或析构出现问题怎么才可以捕捉到呢?
譬如上面一段代码,怎样捕捉到呢
canybox 2007-05-14
  • 打赏
  • 举报
回复
看堆栈,MAIN里面砰在哪个地方?
risefei_sarah 2007-05-14
  • 打赏
  • 举报
回复
#include"TokenPInSpam.h"
#include"TokenPInLegit.h"



int main()
{
SpamFrequency();//统计所有tokens in spam的词频
LegitFrequency();//统计所有tokens in legit的词频

typedef map<string, unsigned int>::iterator typeFreIter;

TokenPInSpam();//计算出所有tokens in spam的概率
TokenPInLegit();//计算出所有tokens in spam的概率

typedef map<string, double>::iterator typePIter;

for (typePIter itReSpam=tokenPInSpamMap.begin(); itReSpam!=tokenPInSpamMap.end(); itReSpam++)
{
for (typePIter itReLegit=tokenPInLegitMap.begin(); itReLegit!=tokenPInLegitMap.end(); itReLegit++)
{
string word = (*itReSpam).first;
double pSpam = 0, pLegit = 0;
string strSpam,strLegit;
strSpam = (*itReSpam).first;
strLegit = (*itReLegit).first;

pSpam = (*itReSpam).second;
pLegit = (*itReLegit).second;
if (strSpam.compare (strLegit) == 0)
{
probabilityMap[word] = (double)pSpam/(pSpam+pLegit);
}
else
{
probabilityMap[word] = (double)pSpam/(pSpam+0);
}
}
}

ofstream outProbabilityFile;
outProbabilityFile.open ("outProbabilityFile.txt");

typedef map<string, double>::iterator typeIter;
for (typeIter it=probabilityMap.begin (); it!=probabilityMap.end(); ++it)
{
outProbabilityFile<<(*it).first<<" "<<(*it).second<<endl;
}

outProbabilityFile.close();

return 0;
}

ps: map声明了好几个全局变量,而且应该都比较大。(统计的1500个垃圾邮件和1500个正常邮件的tokens)
iu_81 2007-05-14
  • 打赏
  • 举报
回复
程序其它地方有问题
应该贴详细一点
  • 打赏
  • 举报
回复
main中return 0;之后还会执行.
main中的class析构
全局变量的析构,静态变量的析构
jixingzhong 2007-05-14
  • 打赏
  • 举报
回复
debug 显示信息可以忽略 ...

检查代码是否存在越界处理。

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧