Debug Assertion Failed! Program:(我编的程序的exe文件的路径) File:strex.cpp Line:332 然后我找到出错
LONGCSmarthome2Dlg::OnComm(WPARAMch,LPARAMport){m_strPortRXData2+=(char)ch;m_strEditD...
LONG CSmarthome2Dlg::OnComm(WPARAM ch, LPARAM port)
{
m_strPortRXData2 += (char)ch;
m_strEditDisData = m_strPortRXData2;
UpdateData(FALSE); //将接收到的字符显示在接收编辑框中
以下设置信号灯状态
for(int i=0;i<4;i++)
{
if(m_strPortRXData2.Mid(i,1)=="1")
SetSwitchStatus(i+1,TRUE);
else
SetSwitchStatus(i+1,FALSE);
}
调用Mid函数 出现断言,怎么办?高手赐教!!
提示出错的那个断言函数如下:
CString CString::Mid(int nFirst, int nCount) const
{
// out-of-bounds requests return sensible things
if (nFirst < 0)
nFirst = 0;
if (nCount < 0)
nCount = 0;
if (nFirst + nCount > GetData()->nDataLength)
nCount = GetData()->nDataLength - nFirst;
if (nFirst > GetData()->nDataLength)
nCount = 0;
ASSERT(nFirst>=0);
ASSERT(nFirst+nCount<=GetData()->nDataLength);
// optimize case of returning entire string
if (nFirst == 0 && nFirst + nCount == GetData()->nDataLength)
return *this;
CString dest;
AllocCopy(dest, nCount, nFirst, 0);
return dest;
} 展开
{
m_strPortRXData2 += (char)ch;
m_strEditDisData = m_strPortRXData2;
UpdateData(FALSE); //将接收到的字符显示在接收编辑框中
以下设置信号灯状态
for(int i=0;i<4;i++)
{
if(m_strPortRXData2.Mid(i,1)=="1")
SetSwitchStatus(i+1,TRUE);
else
SetSwitchStatus(i+1,FALSE);
}
调用Mid函数 出现断言,怎么办?高手赐教!!
提示出错的那个断言函数如下:
CString CString::Mid(int nFirst, int nCount) const
{
// out-of-bounds requests return sensible things
if (nFirst < 0)
nFirst = 0;
if (nCount < 0)
nCount = 0;
if (nFirst + nCount > GetData()->nDataLength)
nCount = GetData()->nDataLength - nFirst;
if (nFirst > GetData()->nDataLength)
nCount = 0;
ASSERT(nFirst>=0);
ASSERT(nFirst+nCount<=GetData()->nDataLength);
// optimize case of returning entire string
if (nFirst == 0 && nFirst + nCount == GetData()->nDataLength)
return *this;
CString dest;
AllocCopy(dest, nCount, nFirst, 0);
return dest;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询