MFC 如何实现CString转DWORD?真的疯了要!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/09 01:56:33
CString转DWORD了,我尝试用下面这个链接的方法,可是报错了~~

http://zhidao.baidu.com/question/91263232.html?si=2

1>f:\c++试验\xv\xv\xvdlg.cpp(185) : warning C4996: “sscanf”被声明为否决的
1> f:\vs 2005 主程序目录\vc\include\stdio.h(311) : 参见“sscanf”的声明
1> 消息:“This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
1>f:\c++试验\xv\xv\xvdlg.cpp(186) : error C2664: “void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)”: 不能将参数 1 从“const char [5]”转换为“const wchar_t *”
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC<wchar_t>
1> ]
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换

你在工程中定义了unicode字符编码
所以CString就等同于CStringW。而char是ascii编码。要在字符串直接赋值是加_T宏
CString str;
TCHAR szChar[] = _T("abcd");
str.Format(_T("%s"), szChar);