int num1,num2,num3;
CString str1,str2,str3;
GetDlgItem(IDC_EDIT1)->GetWindowText(str1);
GetDlgItem(IDC_EDIT2)->GetWindowText(str2);
num1 = _wtoi(str1);
num2 = _wtoi(str2);
num3 = num1 + num2;
_itow(num3,str3,10);
GetDlgItem(IDC_EDIT3)->SetWindowText(str3);
现在编译提示错误“_itow”: 不能将参数 2 从“CString”转换为“wchar_t *”

解决方案 »

  1.   

    WCHAR wch[100];
    _itow(num3,wch,10);但是,你的环境不是unicode ,所以,不能付给CString;
     CStringW str3;
    str3 = wch;
      

  2.   

    //_itow(num3,str3,10);
    str3.Format(_T("%d"), num3);
      

  3.   

    谢谢  我的环境是unicode版本的 我想用数组,想用CString类型的,数组的转换我会 呵呵
      

  4.   

    按这个大哥的方法修改没有问题了 谢谢!我有点不明白的是  如果str3是CString类型的,就不可以用_itow这函数转换了吗?
      

  5.   

    按这个大哥的方法修改没有问题了 谢谢!我有点不明白的是  如果str3是CString类型的,就不可以用_itow这函数转换了吗?
      

  6.   

    _itow第二个参数不接受cstring类型的呀
      

  7.   

    如果str3是CString类型的,就不可以用_itow这函数转换了吗?
    UNICODE环境下, 可以
    多字节环境下, Cstring默认是CStringA,要改为CStringW
      

  8.   

    还是不可以哦  我修改成CStringW了,提示这个错误:
    error C2664: “_itow”: 不能将参数 2 从“CStringW”转换为“wchar_t *”
    int num1,num2,num3;
    CStringW str1,str2,str3;
    GetDlgItem(IDC_EDIT1)->GetWindowTextW(str1);
    GetDlgItem(IDC_EDIT2)->GetWindowTextW(str2);
    num1 = _wtoi(str1);
    num2 = _wtoi(str2);
    num3 = num1 + num2;
    _itow(num3,str3,10);
    GetDlgItem(IDC_EDIT3)->SetWindowTextW(str3);