error C2440: '<function-style-cast>' : cannot convert from 'const

  • Thread starter Thread starter Bit Byte
  • Start date Start date
Bit said:
Are there any macros for converting between these two string types ?

Bit Byte:

Please don't put the whole question in the title.

Very likely you do not really want to make this conversion. You must
understand that in non-Unicode build TCHAR is CHAR (char) while in
Unicode build it is WCHAR (wchar_t). A good way to use the standard
library in Windows programs is

typedef std::basic_string<TCHAR> tstring;
TCHAR str[] = _T("Testing");
tstring s = str;

This will compile in either Unicode or non-Unicode build.

If your program really uses both 8-bit and 16-bit strings you should
look at W2A family of macros, or WideCharToMultiByte().

David Wilkinson
 
Back
Top