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 @ 2016-03-04 09:49  Mungbohne  阅读(104)  评论(0编辑  收藏  举报