?
Solved

compare BSTR

Posted on 2000-02-26
7
Medium Priority
?
3,927 Views
Last Modified: 2008-08-26
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.

0
Comment
Question by:meverest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
7 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2560811


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

Expert Comment

by:Wyn
ID: 2560812


0
 
LVL 5

Expert Comment

by:Wyn
ID: 2560831
sorry,many typo:

int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp(val,str))
return 1;
else return 0;
}
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Expert Comment

by:Wyn
ID: 2560832
sorry,many typo:

int func1(BSTR val)
{
wchar_t str[]=L"true";
if(!wcscmp((wchar_t*)val,str))
return 1;
else return 0;
}
0
 
LVL 5

Accepted Solution

by:
Wyn earned 150 total points
ID: 2560836
hmmm
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2560841
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
0
 
LVL 37

Author Comment

by:meverest
ID: 2562254
thanks, wcscmp() works fine.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question