是不是ASSERT内部包含代码了?

解决方案 »

  1.   

    据我遇到的情况,这个问题发生的主要原因,在于对指针(数组)未作恰当的定义。如,你的字符数组只开到64,而实际中,你对这个数组的使用,超出了它的下界,在debug版中,就可能会没事(debug版总给这个变量留出多余的空间),而在releaseb版中,就不行了。还有一种情况,在Release版中打开的某种优化开关,导致生成的目标代码有差别,这是由于没有严格地按照语法书写语句。最好把编译时的警告级别设到最大,消除一切警告。再有就是比较“愚蠢”的错误了,条件编译设的不对,导致有些代码在两种版本中被作不同的处理。
      

  2.   

    在debug写入什么,就读出什么,而在release状态下,读出的前五位为1702124788,1667592812,1550086767,1819029094,108,显然是随机生成的长整型;
    void CGh2Dlg::OnSave() 
    {
    this->UpdateData(true); 

    long work;
    long pass;
    int Line[64];
    for (int k=0;k<64;k++)
    {
    Line[k]=100;
    }
    if ((m_work==0)||(m_pass==0))
    {
    MessageBox("请检查您的工号和密码!");
    return;
    }
    work=m_work;
    pass=m_pass;
    CString str;
    str.Format("%d",work);
    str+=" "; if (m_bChoiceAll)
    {
    for (int iii=0;iii<64;iii++)
    {
    Line[iii]=200;
    }
    str+="全选";
    m_CtrListMessage.AddString(str);
    }
    else
    {
    bool is_NotChoice=false;
    bool is_allChoice=false;
    for (int j=0;j<32;j++)
    {
    CButton* pButton=(CButton*)GetDlgItem( IDC_CHECK1+j );
    if (pButton->GetState())
    {
    is_NotChoice=true;
    break;
    }
    }
    for (int jj=0;jj<32;jj++)
    {
    CButton* pButton=(CButton*)GetDlgItem( IDC_CHECK33+jj );
    if (pButton->GetState())
    {
    is_NotChoice=true;
    break;
    }
    }
    for (int jjj=0;jjj<32;jjj++)
    {
    CButton* pButton=(CButton*)GetDlgItem( IDC_CHECK1+jjj );
    if (!pButton->GetState())
    {
    is_allChoice=true;
    break;
    }
    }
    for (int jjjj=0;jjjj<32;jjjj++)
    {
    CButton* pButton=(CButton*)GetDlgItem( IDC_CHECK33+jjjj );
    if (!pButton->GetState())
    {
    is_allChoice=true; 
    break;
    }
    }
    if (!is_NotChoice)
    {
    MessageBox("请选择线路!");
    return;
    }
    if (!is_allChoice)
    {
    MessageBox("请您直接选择全选!");
    return;
    }
    for (int i=0;i<32;i++)
    {
    CButton* pButton=(CButton*)GetDlgItem( IDC_CHECK1+i );
    int flag;
    flag=pButton->GetState();
    if (flag)
    {
    Line[i]=i;
    CString str1;
    str1.Format("%d",Line[i]);
    str+=" ";
    str+=str1;
    }
    else
    Line[i]=100;

    for (int k=0;k<32;k++)
    {
    CButton *pButton=(CButton*)this->GetDlgItem(IDC_CHECK33+k);
    if (pButton->GetState())
    {
    Line[32+k]=(32+k);
    CString str1;
    str1.Format("%d",Line[32+k]);
    str+=" ";
    str+=str1;

    else
    Line[32+k]=100;
    }
    m_CtrListMessage.AddString(str);
    }
    char lpszPathName[20];
    sprintf( lpszPathName, "C:\\Program Files\\录音\\telrecord\\f.lll");
    if( _access(lpszPathName, 0)!=0 )
    _mkdir( lpszPathName );
    CFile file;
    file.Open(lpszPathName,CFile::modeWrite);
    file.SeekToEnd(); 
    file.Write(&work,sizeof(long));
    file.Write(&pass,sizeof(long));
    for (int l=0;l<64;l++)
    {
    file.Write(&Line[l],sizeof(int));
    }
      file.Close();
    for (int i=0;i<32;i++)
    {
    CButton *pButton=(CButton*)this->GetDlgItem(IDC_CHECK1+i);
    pButton->SetCheck(0);
    }
    for (int ii=0;ii<32;ii++)
    {
    CButton *pButton=(CButton*)this->GetDlgItem(IDC_CHECK33+ii);
    pButton->SetCheck(0);
    }
    }
    BOOL CGh2Dlg::OnInitDialog()
    {
    CDialog::OnInitDialog();
    CFile file = NULL;
    long work;
    long pass;
    int linex[64];
    char szFileName[20];
    sprintf( szFileName, "C:\\Program Files\\录音\\telrecord\\f.lll");
    if( !file.Open(szFileName, CFile::modeRead) ){
    AfxMessageBox("读文件f.lll!");
    return FALSE;
    }
    int readLength=0;
    int stateLength=file.GetLength();
    if ((stateLength%264)!= 0 )
    {
    AfxMessageBox("文件存储出现问题!");
    file.Close();
    return FALSE;
    }
    file.SeekToBegin();
    while (readLength<stateLength)
    {
    CString str,str1;
    file.Read(&work, sizeof(long));
    file.Read(&pass,sizeof(long));  
    str1.Format("%d",work);
    str+=str1;
    if (work==0)
    {
    file.Read(linex,64*sizeof(int));
    readLength+=264;
    continue;
    }
    else
    {
    int  is_choice=0;
    for (int i=0;i<64;i++)
    {
    int Line=100;
    file.Read(&Line,sizeof(int));
    if (Line==200)
    {
    str+=" 全选";
    m_CtrListMessage.AddString(str);
    file.Seek(252,CFile::current);
    break;
    }
    else if (Line!=100)
    {
    CString str2;
    str2.Format("%d",Line);
    str+=" ";
    str+=str2;
    is_choice++;
    }
    }
    if(is_choice!=0)
    m_CtrListMessage.AddString(str);
    readLength+=264;
    }
    }
    file.Close();
    return TRUE;  // return TRUE  unless you set the focus to a control
    }
      

  3.   

    int c=1;
    cout<<++c<<++c<<++c;以上的程序在vc里面两种编译的结果都不一样,天知道.