开发者

Assertion Error During Running the program

I made a program in Visual Studio 2008 using C++ language and MFC Files. It is a graphical user interface which store student records in a file using file handling of C++. It is working properly and shows or adds records but when I try to modify and delete records it will give a assert开发者_如何学Goion error to me while running.

Please help me out.

Functions code that I use for modify and delete records are here.

void modifyrec()
{
    Invalidate();

    bool found;

    struct student e;

    getname_dialog diag;
    if(diag.DoModal()==IDOK)
    {
        found = false;

        fp.SeekToBegin();

        while(fp.Read(&e,sizeof(e))>=sizeof(e))
        {
            if(e.batch_no==g_batchno && strcmp(e.name,g_name)==0)
            {
                found = true;
                break;
            }
        }

        if(found == true )
        {
            modify_dialog mdiag(e);
            mdiag.DoModal();
        }
        else
            MessageBox("Record Not Found","Modify Record....");
    }
}

void delrec()
{
    bool foun;
    struct student e;

    Invalidate();

    getname_dialog diag;
    if(diag.DoModal()==IDOK)
    {
        found = false;
        fp.SeekToBegin();

        CFile ft("temp.dat",CFile::modeCreate | CFile:modeWrite);
        while(fp.Read(&e,sizeof(e))>= sizeof(e))
        {
            if(e.batch_no==g_batchno && strcmp(e.name,g_name)==0)
            {
                found = true;
                break;
            }
        }

        if(found == true )
        {
            modify_dialog mdiag(e);
            mdiag.DoModal();
        }
        else
            MessageBox("Record Not Found","Delete Record....");


        fp.Close();
        ft.Close();

        CFile::Remove("students.dat");
        CFile::Rename("temp.dat","student.dat");
        fp.Open("students.dat",CFile::modeCreate |CFile::modeNoTruncate |CFile::modeReadWrite);
    }
}


You seem to have removed one or more controls from the dialog resource, and DoDataExchange is still referring them (via of one DDX_Control functions). Find out what those resources are, and remove the references of them from DoDataExchange.

Later you may remove those control IDs (IDC_) from resource.h altogether if they are not used by other dialogs in your project.

To find out unused resource IDs do:

  • Goto Resource View
  • Select the appropriate .RC file
  • Right click and click Resource Symbols..
  • In the dialog box, find out unused IDs (not having check at them)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜