运行老出现Assertion Failed。
各位朋友,我在EVC下写了这样一个程序,编译能通过,但运行是老 出现Assertion Failed这个错误。
程序是这样的:
我建了一个对话框的程序:
首先点按钮生成一个对话框 CDlgEdit:
void CManeger007Dlg::OnBtnadd()
{
// TODO: Add your control notification handler code here
m_operID = 0;//注释掉后程序可运行
CDlgEdit Dlg(this);//注释掉后程序可运行
Dlg.DoModal();//注释掉后程序可运行
}
然后我在生成的对框的按钮时又添加了如下代码:
void CDlgEdit::OnBtnsave()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
// 以下代码用于把时间提出出来,放到结构体中
alarm alarmtime;
CTime time;
time = m_time1.GetTime(time);
alarmtime.m_year = time.GetYear();
alarmtime.m_month = time.GetMonth();
alarmtime.m_day = time.GetDay();
time = m_time2.GetTime(time);
alarmtime.m_year = time.GetHour();
alarmtime.m_month = time.GetMinute();
alarmtime.m_day = time.GetSecond();
// 以上代码用于把时间提出出来放到结构体中
bool operID = ((CManeger007Dlg*)GetParent())->m_operID;
if(operID == 0)
{ //是添加操作,要建立一个新文件
UpdateData(TRUE);
CString contents,topic,filename;
topic = m_topic; //保存输入的文件名,也就是主题
topic += ".dat"; //完整的文件名+.dat
filename= "\\My Documents\\" ;
filename += topic; //路径名+文件名
contents = m_contents;
TCHAR array [100];
wcscpy(array,contents); // 把内容转化成数组,以便保存。
CFile file;
file.Open(filename,CFile::modeCreate | CFile::modeWrite);
file.Write(&alarmtime,sizeof(alarmtime)); //把时间保存
file.Write(array,100); //保存内容
((CManeger007Dlg*)GetParent())->m_ListTopic.AddString(topic);
this->EndDialog(0); // 关闭对话框
}
else
{ //是编辑操作
}
}
大概的代码就是这样的,这是怎么回事啊?我刚学这东西,调试还不会。