C++ MFC how to compare LPCTSTR in a if statement?

Posted by user1078510 on Stack Overflow See other posts from Stack Overflow or by user1078510
Published on 2012-03-20T23:19:01Z Indexed on 2012/03/20 23:29 UTC
Read the original article Hit count: 143

Filed under:
|
|
|
|

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!

© Stack Overflow or respective owner

Related posts about c++

Related posts about string