Reputation: 540
I have downloaded an sample code, so there are some CString variables in that code which are passed to the sscanf() function as char* the compiler implicitly converts those CString and the code complie fine.the code which works fine is here:
CString m_strVersionXFS;
m_strVersionXFS = _T("00029903");
DWORD nVersion;
sscanf(m_strVersionXFS,"%08X",&nVersion);
the problem is here when i tried to write my own simple code which tries to manipulate a CString variable in the same way but the compiler says which can't convert a CString to a cahr*
Upvotes: 0
Views: 1364
Reputation: 22683
I suspect that your own code is using unicode (UNICODE
constant defined). This means that CString
is using wide characters, and will implicitly convert to wchar_t*
, but not to char*
.
If that is the case, there are three possible solutions:
swscanf
, the wide character version of sscanf
(recommended);CStringA
instead of CString
so you're using the ANSI version of CString
;Upvotes: 3