应该很简单的问题,SORRY;下面这段程序是仓库管理系统的一段解析调试程序,就是把ctrllist控件里的列,先赋值到一组指针里,然后将其中需要解析的STRINGS[2]进行解析,在程序最后的两个MessageBox弹出的书记证明解析是对了,问题是在解析完后,程序弹出一个运行错的大提示框,上面提示什么:
             Debud Assert Failed!
             exception: _CrtIsvalidheadPointer(pUserdata)
我是用CTRL+F10进行调试的,在程序退出到最后一行也没错,就是退不出去,还是怎么回事那,请高手指点迷津!!                
void DoDailywork::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult) 
{
// TODO: Add your control notification handler code here
int i=m_salelist.GetSelectionMark();
CString strSQL;
if (i==-1) {
MessageBox("要删除记录,请先选择!");
return;
}
//strSQL.Format("delete from %s where ID = %d ",\
// m_storename,atoi(m_salelist.GetItemText(i,0)) );
// db.ExecuteSQL(strSQL);
// RefreshData();
//解析列表为数据库的字段值
LPTSTR STRINGS[6] ;
for (int j=0; j<=6; j++)  
STRINGS[j]=(LPTSTR)malloc(sizeof(char)*40);
for (j=0; j<=6; j++)
sprintf(STRINGS[j], "%s", m_salelist.GetItemText(i,j));
//解析商品规格
char type[11+1],type1[11],type2[11];
memset(type,0,sizeof(type));
memset(type1,0,sizeof(type));
memset(type2,0,sizeof(type));
sprintf(type,"%s",STRINGS[2]);
int fx,iweight,inumber,len;
fx=j=iweight=inumber=0;
//len=strlen(type);
while (*type) {
if ( type[j] ==  '*' ) {
if (fx == 0 ) {
fx = 1;
inumber = j+1;      //规格数量的起始位置
}
else if (fx == 1) {
fx=2;iweight = j+1; //规格重量的起始位置
}
}
j++;   //
}

if (fx == 1) {
strncpy(type1,type+inumber,j-inumber);
type1[j-inumber]=0;
MessageBox((const char *)type1);
}
if (fx == 2) {
strncpy(type1,type+inumber,iweight-inumber-1);
type1[iweight-inumber-1]=0;
strncpy(type2,type+iweight,j-iweight-2);
type2[j-iweight-2]=0;
MessageBox((const char *)type1);
MessageBox((const char *)type2);
}
for (int k = 0; k<6; k++)
free((LPTSTR)STRINGS[k]);
//switch flag1值及m_storename值,flag2值来确定操作方向,分入库,出库;
//出库又要针对是否自动记帐进行区分;


//
*pResult = 0;
}

解决方案 »

  1.   

    上文的“书记”更正为“数据”,SORRY;
    另外,在线等,请高手赶快下手,谢谢
      

  2.   

    Debud Assert Failed!
                 
    好象是不能弹出调试的信息,这对程序应该没问题,RELEASE版本试试。
      

  3.   

    我还是不能明白,是不是那些指针用的不对,释放的方式不对,这个LPTSTR说实话,我也是不加思索,凭在UNIX下的知识,想当然的使用;
    难道,Debug下的错没关系吗,我好像还是不明白个究竟?
      

  4.   

    Debud Assert Failed!
    下面有出错的文件和位置,去看看。