【问题标题】:Cannot Convert const char* to int in MFC(VC++)?无法在 MFC(VC++) 中将 const char* 转换为 int?
【发布时间】:2010-11-29 15:48:59
【问题描述】:
I am appending one CString value with integer but getting error as "Cannot Convert const char* to int .
int iFolderType = 0;
CString strCurrFolder = "";
                    HShareFolder = m_pTreeview->InsertItem(strCurrFolder,hChildItem);                   
                    m_pTreeview->SetItemImage(HShareFolder,2,2); 

                if(bCheck == false)
                {
                     iFolderType = eBOTH;

                }
                else
                {
                     iFolderType = eCIFS;
                }   

                strCurrFolder.Append("|");
                strCurrFolder.Append(iFolderType); //This line gives error
                m_strFolderTypeList.AddHead(strCurrFolder);  

【问题讨论】:

    标签: visual-c++ mfc


    【解决方案1】:

    您必须将其转换为 CString 或 const char*。最简单的方法是使用 CString::Format

    CString strFolderType;
    strFolderType.Format(_T("%d"), iFolderType);
    strCurrFolder += strFolderType;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 2014-03-02
      • 2018-11-16
      • 2020-04-04
      • 2020-01-23
      • 1970-01-01
      相关资源
      最近更新 更多