c++visual-studio-2008portingvisual-c++-6

Cannot convert from 'const wchar_t *' to '_TCHAR *'


_TCHAR* strGroupName = NULL;
const _TCHAR* strTempName = NULL;

//Assign some value to strTempName

strGroupName = _tcschr(strTempName, 92) //C2440

I get an error at the above line while compiling this code in VS2008. In VC6 it compiles fine.

Error C2440: '=' : cannot convert from 'const wchar_t *' to '_TCHAR *'

What seems to be the problem and how do I fix it?


Solution

  • Try casting it as

    strGroupName = (_TCHAR*)_tcschr(strTempName, 92);
    

    Seems to me that VS2008 got a little more strict on type casts, and won't automatically do them in some cases.