meverest
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.
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.
sorry,many typo:
int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp(val,str))
return 1;
else return 0;
}
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,s tr))
return 1;
else return 0;
}
int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp((wchar_t*)val,s
return 1;
else return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
thanks, wcscmp() works fine.
int func1(BSTR val)
{
wchar_t str[]=L"true";
wchar_t* temp=val;
if(!wcscmp(++temp, temp))
return 1;
else return 0;
}