I have the following code:
LPCTSTR strPermission = Method();
if (strPermission == L"0")
{
    return true;
}
else
{
    return false;
}
While debugging I can see that strPermission does equal "0", yet when I compare it like in the if statement it always returns false.
The only thing I can think of is that it is comparing the memory address of the variable rather than the variable value.
How do I compare strPermission to L"0" so that it would return true if strPermission equals "0".
Thank you!
You'll need to use a C runtime library function. strcmp compares ANSI strings, wcscmp compares UNICODE strings.
You use it like this:
bool match = wcscmp(strPermission, L"0") == 0;
You can't compare C-style strings like that in C or C++. Check out this C FAQ question & answer.
The function you're looking for is called lstrcmp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With