convert
-
MFC, STUDIO 2008, Project use UNICODE CString m_sTest; m_sTest = L"Байкал"; char *m_pchar3; m_pchar3 = new char[70]; How todo m_sTest into m_pchar3? //- m_pchar3=m_sTest; // error C2440: '=' : cannot convert from 'CString' to 'char *' //- strcpy(m_pchar3, m_sTest); // error C2664: 'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *' //- strcpy(m_pchar3, (TCHAR)m_sTest); // error C2440: 'type cast' : cannot convert from 'CString' to 'TCHAR' //- _tcscpy( m_pchar3, (TCHAR*)(LPCTSTR)m_sTest ); // error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
-
MFC, STUDIO 2008, Project use UNICODE CString m_sTest; m_sTest = L"Байкал"; char *m_pchar3; m_pchar3 = new char[70]; How todo m_sTest into m_pchar3? //- m_pchar3=m_sTest; // error C2440: '=' : cannot convert from 'CString' to 'char *' //- strcpy(m_pchar3, m_sTest); // error C2664: 'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *' //- strcpy(m_pchar3, (TCHAR)m_sTest); // error C2440: 'type cast' : cannot convert from 'CString' to 'TCHAR' //- _tcscpy( m_pchar3, (TCHAR*)(LPCTSTR)m_sTest ); // error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
Why do you need to do that? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
MFC, STUDIO 2008, Project use UNICODE CString m_sTest; m_sTest = L"Байкал"; char *m_pchar3; m_pchar3 = new char[70]; How todo m_sTest into m_pchar3? //- m_pchar3=m_sTest; // error C2440: '=' : cannot convert from 'CString' to 'char *' //- strcpy(m_pchar3, m_sTest); // error C2664: 'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *' //- strcpy(m_pchar3, (TCHAR)m_sTest); // error C2440: 'type cast' : cannot convert from 'CString' to 'TCHAR' //- _tcscpy( m_pchar3, (TCHAR*)(LPCTSTR)m_sTest ); // error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
CHIVOTIOV wrote:
char *m_pchar3; m_pchar3 = new char[70];
Use
TCHAR
instead ofchar
.
Too many passwords to remember? Try KeePass Password Safe!
-
MFC, STUDIO 2008, Project use UNICODE CString m_sTest; m_sTest = L"Байкал"; char *m_pchar3; m_pchar3 = new char[70]; How todo m_sTest into m_pchar3? //- m_pchar3=m_sTest; // error C2440: '=' : cannot convert from 'CString' to 'char *' //- strcpy(m_pchar3, m_sTest); // error C2664: 'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *' //- strcpy(m_pchar3, (TCHAR)m_sTest); // error C2440: 'type cast' : cannot convert from 'CString' to 'TCHAR' //- _tcscpy( m_pchar3, (TCHAR*)(LPCTSTR)m_sTest ); // error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
-
MFC, STUDIO 2008, Project use UNICODE CString m_sTest; m_sTest = L"Байкал"; char *m_pchar3; m_pchar3 = new char[70]; How todo m_sTest into m_pchar3? //- m_pchar3=m_sTest; // error C2440: '=' : cannot convert from 'CString' to 'char *' //- strcpy(m_pchar3, m_sTest); // error C2664: 'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *' //- strcpy(m_pchar3, (TCHAR)m_sTest); // error C2440: 'type cast' : cannot convert from 'CString' to 'TCHAR' //- _tcscpy( m_pchar3, (TCHAR*)(LPCTSTR)m_sTest ); // error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
CHIVOTIOV wrote:
/ error C2664: 'wcscpy' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
Just a padding to the other replies here. As the above lines says, You are trying to squeeze a 2 Byte string (UNICODE) into a single byte string(ANSI). char , std::string , etc by default belong to the single byte representation. wchar_t, std::wstring, etc represent UNICODE representation. TCHAR is "neutral" based on the scheme used, it switches type accordingly. If you define # UNICODE in the setting, the string becomes 2 byte reps. If you don't define it, it becomes single byte. Also when you use TCHARs, you should use strings apis specific to TCHARs. (like _tcscpy) that assures complete independence to your character-set implementations. Similarly, CString switches types based on the project character-set settings.(UNICODE/Single-byte). Now you have defined UNICODE in your project settings but trying a cross-copy operation. So just figure out what needs to be done.. :)
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus