vs lesson7

cstring和int转换

复制代码
CString m_str1,m_str2,m_str3;
    char ch1[10],ch2[10],ch3[10];
    int num1, num2, num3;
    GetDlgItem(IDC_EDIT1)->GetWindowTextW(m_str1);
    GetDlgItem(IDC_EDIT2)->GetWindowTextW(m_str2);
    
    num1 = _ttoi((LPCTSTR)m_str1);
    num2 = _ttoi((LPCTSTR)m_str2);
    num3 = num1 + num2;
    m_str3.Format(_T("%d"), num3);
    //_tstoi(num3, (TCHAR*)m_str3.GetBuffer(10), 10);
    //m_str3.ReleaseBuffer();
    
    GetDlgItem(IDC_EDIT3)->SetWindowTextW(m_str3);
复制代码

 

posted @   Mungbohne  阅读(105)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示