"Void Atl::cstringt<basetype,stringtraits>::format (const wchar_t *,...)": cannot convert parameter 1 from "const char [29]"
The above problem should be used with multibyte character set
Case address, Baidu know quote
Problem:
"Void Atl::cstringt<basetype,stringtraits>::format (const wchar_t *,...)
cstring strdate,strtime;
systemtime St; Gets the local time
getlocaltime (&st);
strdate.format ("%4d-%2d-%2d", st.wyear,st.wmonth,st.wday);
strtime.format ("%4d:%2d:%2d" ", St.whour,st.wminute,st.wsecond);
getdlgitem (Idc_static_time)->setwindowtext (strdate + strTime);
settimer (1,1000,null);
return TRUE;
error C2664: "Void Atl::cstringt<basetype,stringtraits>::format ( Const wchar_t *,...) ": cannot convert parameter 1 from" const char [12] "to" Const wchar_t * "
1> Build failed.
answer:
You use a VC2005 or a higher version of it?
VC2005 and later versions use the Unicode character set by default, and CString is a wide character, that is, wchar_t, not char. You can write this:
Strdate.format (_t ("%4d-%2d-%2d"), St.wyear,st.wmonth,st.wday);
Strtime.format (_t ("%4d:%2d:%2d"), St.whour,st.wminute,st.wsecond);
To write the program later, define the string variable, do not use char*, and use tchar*. All string constants, not directly with "", but with _t (""). As an example:
tchar* str = _t ("Hello, World");
Of course, what I said above is in MFC. If you write a console program, you don't have to.
Using the "Unicode Character set" error, you should use the "use multibyte Character set"