我在VC++6.0下编写了如下程序:
CCnvDecode214::Get2BinCodes(int i)
{
CString n;
n = m_szInputCode.GetAt(i * 2);
m_szTwoBit = n;
n = m_szInputCode.GetAt(i * 2 + 1);
m_szTwoBit = m_szTwoBit + n;
}
从m_szInputCode中提取两位存入m_szTwoBit中,编译链接通过,但程序运行时在倒数第二行m_szTwoBit = m_szTwoBit + n;;处会报错:Debug Assertion Faild!不知是何原因,请指点CSting如何在结尾追加字符,谢过!!!

解决方案 »

  1.   

    为什么编译时提示CString没有Append成员函数?这两天被CString弄得十分晕,不是说CString支持“+”运算符吗?不知为什么不行。而且我感觉我的问题是出在内存分配上。还望高手继续指点!谢谢!
      

  2.   

    将CString转换城CComBSTR 类型
    CComBSTR 才有Append函数。
      

  3.   

    你的 CString 没有 Append 方法吗? 
    晕啊 ...
      

  4.   

    CString n;
    n = m_szInputCode.GetAt(i * 2);
    m_szTwoBit = n;
    n = m_szInputCode.GetAt(i * 2 + 1);
    m_szTwoBit = m_szTwoBit + n;
    //光光这段代码看不出问题,需要上下文