大家好:
CString s; 
int i = 64; 
s.Format("%d", i);以上代码在运行的时候出现以下异常,
e:\uniargusvc\andytest\andytest\test.cpp(11) : error C2664: “void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)”: 不能将参数 1 从“const char [3]”转换为“const wchar_t *”
1>        with
1>        [
1>            BaseType=wchar_t,
1>            StringTraits=StrTraitMFC_DLL<wchar_t>
1>        ]
1>        与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换请问是什么原因呀!我该怎么修改!谢谢!

解决方案 »

  1.   

    s.Format(_T("%d"), i);  //UNICODE版

    CStringA s; 
    int i = 64; 
    s.Format("%d", i);
      

  2.   

    s.Format(_T("%d"),i);你启用了uncode字符集
      

  3.   

    我是新手,不太懂,启用了unicode字符集是什么意思?
      

  4.   

    就是工程默认用了 UNICODE 编码方式, 改一下设置就可以了, 比如 VC++2005 中这样修改:
    项目 -> 属性 -> 配置属性 -> 常规 -> 字符集
    由"使用 Unicode 字符集" 改为 "未设置"