Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

compare BSTR

Posted on 2000-02-26
7
Medium Priority
?
3,944 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

636 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