在MFC(VC ++)中无法将const char *转换为int?

时间:2010-11-29 07:35:47

标签: visual-c++ mfc

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);  

1 个答案:

答案 0 :(得分:0)

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

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