I have a TCHAR define below:
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
and I want to comapare as below:
if(szProcessName == "NDSClient.exe")
{
}
But then I am getting the errors:
error C2446: == : no conversion from const char * to TCHAR *
error C2440: '==' : cannot convert from 'const char [14]' to 'TCHAR [260]'
"NDSClient.exe"
is aconst char*
string on windows. If you want it to become aconst TCHAR*
then you need to use theTEXT
macro. Also, you can not compare strings using==
use a equivalentTCHAR
function such as_tcscmp
.Also you can use.
L"some string"
to make TCHAR*. But I suggest you to usestd::wstring
(analog ofstd::string
and asstd::string
needs#include <string>
) instead of TCHAR*.example: