Link to home
Start Free TrialLog in
Avatar of meverest
meverestFlag for Australia

asked on

compare BSTR

Hi Folks,

what is your preferred way of comparing BSTRs - this is the only way i know:

int func1(BSTR val)
{
if(!strcmp((char *)val, "true")) return 1;
else return 0;
}

not surprising this doesn't work anyway...

thanks and regards.

Avatar of Wyn
Wyn



int func1(BSTR val)
{
wchar_t str[]=L"true";
wchar_t* temp=val;
if(!wcscmp(++temp, temp))
return 1;
else return 0;
}
sorry,many typo:

int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp(val,str))
return 1;
else return 0;
}
sorry,many typo:

int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp((wchar_t*)val,str))
return 1;
else return 0;
}
ASKER CERTIFIED SOLUTION
Avatar of Wyn
Wyn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here code again in case mess you up:)

int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp((wchar_t*)val, str))

//or simply use wcscmp((...),L"true")

return 1;
else return 0
}

Regards
W.Yinan
Avatar of meverest

ASKER

thanks, wcscmp() works fine.