VC data convert listing

VC data convert listing

    CString Convert to LPCTSTR 
       CString strResult;
       strResult.Format(“Hi:%d”,5);
       static CString Rxg=_T(strResult);
       LPCTSTR g_DisplayMessage;
       g_DisplayMes=Rxg;

    CString to int 

    CString String;
    String.Format(“%d”, 10);
    int Integer = atoi(String);

     

     

    CString to std::string

    CString cs(“Hello”);
    std::string s((LPCTSTR)cs);

    std::string to CString

    std::string strStdString (“Hello!”);
    CString strCString (strStdString.c_str ());

     std::string to int

      std::string t_port=”xxx”; 
      int  m_Port=atoi(t_port.c_str());

    Convert VARIANT to CString

    VARIANT vaData=t_1;
    ASSERT(vaData.vt == VT_BSTR);
    CString strData(vaData.bstrVal);

     

    BSTR to CString

     

    BSTR t_MSG;
    CString szCS;
    szCS = (CString)t_MSG;