创建了自定义的非MFC类,无继承。调试时到析构函数结束都没有以上错误跳出,但是过了析构函数后就跳出了这个错误提示,汇编调试窗口显示的出错地址在AfxWinMain入口函数出,不知道是不是因为这个类动态分配内存的缘故,不过我在析构函数了已经销毁了这些动态struct结构阿,百思不得其解。
部分代码:
MIFRestore m_mif;
m_mif.open(filename);//导入文件数据
m_mif.inistance();//将数据动态写入自定义的结构体////////////////////////////////////////
MULTIPOINT结构的写入
///////////////////////////////////////
bool MIFRestore::WriteMifMultipoint(CString str,int &iIndex)
{
CString m_temp;
(m_mifdata.multipoint+count[1])->ID=count[1];
int temp;
temp=atoi(str);
(m_mifdata.multipoint+count[1])->number=temp;
if(temp>1)
{
double *pxy=new double[2*temp];
(m_mifdata.multipoint+count[1])->x=new double[temp];
(m_mifdata.multipoint+count[1])->y=new double[temp];
iIndex++;
str=*(pString+iIndex);
for(int j=1;j<temp;j++)
{
iIndex++;
str=str+' '+*(pString+iIndex);
}
ReDivide(str,pxy);
GetXY(pxy,(m_mifdata.multipoint+count[1])->x,
(m_mifdata.multipoint+count[1])->y,2*temp);
delete[] pxy;
}
else
{
(m_mifdata.multipoint+count[1])->x=new double;
(m_mifdata.multipoint+count[1])->y=new double;
iIndex++;
str=*(pString+iIndex);
double pxy[2];
ReDivide(str,pxy);
(m_mifdata.multipoint+count[1])->x[0]=pxy[0];
(m_mifdata.multipoint+count[1])->y[0]=pxy[1];
}
iIndex++;
str=*(pString+iIndex);
str.TrimLeft();
m_temp=Divide(str);
str.Delete(0,m_temp.GetLength());
str.TrimLeft();
ReDivide(str,style);
(m_mifdata.multipoint+count[1])->point_shape=style[0];
(m_mifdata.multipoint+count[1])->point_color=style[1];
(m_mifdata.multipoint+count[1])->point_size=style[2];
count[1]++;
return true;
}
/////////////////////////////////
析构MUlLTIPOINT结构
////////////////////////////////
if(count[1]>0)
{
for(i=0;i<count[1];i++)
{
if((m_mifdata.multipoint+i)->number>1)
{
delete[] (m_mifdata.multipoint+i)->x;
delete[] (m_mifdata.multipoint+i)->y;
}
if((m_mifdata.multipoint+i)->number==1)
{
delete (m_mifdata.multipoint+i)->x;
delete (m_mifdata.multipoint+i)->y;
}
}
}
if(i>0)
delete[] m_mifdata.multipoint;
部分代码:
MIFRestore m_mif;
m_mif.open(filename);//导入文件数据
m_mif.inistance();//将数据动态写入自定义的结构体////////////////////////////////////////
MULTIPOINT结构的写入
///////////////////////////////////////
bool MIFRestore::WriteMifMultipoint(CString str,int &iIndex)
{
CString m_temp;
(m_mifdata.multipoint+count[1])->ID=count[1];
int temp;
temp=atoi(str);
(m_mifdata.multipoint+count[1])->number=temp;
if(temp>1)
{
double *pxy=new double[2*temp];
(m_mifdata.multipoint+count[1])->x=new double[temp];
(m_mifdata.multipoint+count[1])->y=new double[temp];
iIndex++;
str=*(pString+iIndex);
for(int j=1;j<temp;j++)
{
iIndex++;
str=str+' '+*(pString+iIndex);
}
ReDivide(str,pxy);
GetXY(pxy,(m_mifdata.multipoint+count[1])->x,
(m_mifdata.multipoint+count[1])->y,2*temp);
delete[] pxy;
}
else
{
(m_mifdata.multipoint+count[1])->x=new double;
(m_mifdata.multipoint+count[1])->y=new double;
iIndex++;
str=*(pString+iIndex);
double pxy[2];
ReDivide(str,pxy);
(m_mifdata.multipoint+count[1])->x[0]=pxy[0];
(m_mifdata.multipoint+count[1])->y[0]=pxy[1];
}
iIndex++;
str=*(pString+iIndex);
str.TrimLeft();
m_temp=Divide(str);
str.Delete(0,m_temp.GetLength());
str.TrimLeft();
ReDivide(str,style);
(m_mifdata.multipoint+count[1])->point_shape=style[0];
(m_mifdata.multipoint+count[1])->point_color=style[1];
(m_mifdata.multipoint+count[1])->point_size=style[2];
count[1]++;
return true;
}
/////////////////////////////////
析构MUlLTIPOINT结构
////////////////////////////////
if(count[1]>0)
{
for(i=0;i<count[1];i++)
{
if((m_mifdata.multipoint+i)->number>1)
{
delete[] (m_mifdata.multipoint+i)->x;
delete[] (m_mifdata.multipoint+i)->y;
}
if((m_mifdata.multipoint+i)->number==1)
{
delete (m_mifdata.multipoint+i)->x;
delete (m_mifdata.multipoint+i)->y;
}
}
}
if(i>0)
delete[] m_mifdata.multipoint;
解决方案 »
- 一个服务器开两个客户端怎样实现?
- 如何判断鼠标移动到工具栏的某项
- 动态创建RichEdit的简单问题,答者有分
- IPicture::Render将一图片缩小后,再调整图片位置的时候,速度很慢,有知道的吗?
- 基于CFormView,把对话框分成左半部和右半部,我需要控制对话框只显示左半部或显示全部,有什么简单的方法
- 请问MFC如何实现从FOXPRO的DBF文件中读取数据?
- 有关可行性报告!
- 关于串口程序的问题
- 在MFC中如何在链表中嵌套CString类,我的链表出现了没有想到的错误
- 多个线程操作多个对象,应该使用一个互斥对象还是多个互斥对象对这些对象进行同步。
- 如何窗口小到一定尺寸,就不能在小了.就像qq那样.
- 请问:我想学VC ,请大家给我推荐一本好书!!!!thx!
不过一定是你的程序引起的
仔细检查你的new和delete
INFO: First and Second Chance Exception Handling (Q105675)
Structured exception handling (SEH) takes a little getting used to, particularly when debugging. It is common practice to use SEH as a signaling mechanism. Some application programming interfaces (APIs) register an exception handler in anticipation of a failure condition that is expected to occur in a lower layer. When the exception occurs, the handler may correct or ignore the condition rather than allowing a failure to propagate up through intervening layers. This is very handy in complex environments such as networks where partial failures are expected and it is not desirable to fail an entire operation simply because one of several optional parts failed. In this case, the exception can be handled so that the application is not aware that an exception has occurred. However, if the application is being debugged, it is important to realize that the debugger will see all exceptions before the program does. This is the distinction between the first and second chance exception. The debugger gets the "first chance," hence the name. If the debugger continues the exception unhandled, the program will see the exception as usual. If the program does not handle the exception, the debugger will see it again (the "second chance"). In this latter case, the program normally would have crashed had the debugger not been present. If you do not want to see the first chance exception in the debugger, then disable the feature. Otherwise, during execution, when the debugger gets the first chance, continue the exception unhandled and allow the program to handle the exception as usual. Check the documentation for the debugger that you are using for descriptions of the commands to be used.
刚才我写的代码就是简单的读文件,在关闭文件句柄的时候系统NTDLL出错,都是告诉heap出错
代码本身没有问题,而是读取的文件有问题,读别的文件就没有问题,读该文件就报错