Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data Type question

Posted on 1998-08-31
1
Medium Priority
?
166 Views
Last Modified: 2010-04-10
I have a snippet of code:
for (i=0; i<TagCount; i++)
{
iErr = ADL_Tag_Get(TDL, i + 1, &TagInfo);
if (TagInfo.name == "ZIP4")    //error here
break;
}

It gives me this error:
'==' : no conversion from 'char *' to 'unsigned char *'
                        
0
Comment
Question by:ds1964
[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
1 Comment
 
LVL 2

Accepted Solution

by:
milenvk earned 120 total points
ID: 1171763
I assume you are programming for any of the Windows operating systems.

This code here will do the job:

if(wcscmp(TagInfo.name, L"ZIP4") == 0) // error here
  break;

See, fisrt I don't think that '==' is the operator that will help you for string comparison. '==' compares the two pointers not the two strings. Further if you look at the declaration of the structure/class of TagInfo you will probably see that 'name' is of type LPWSTR or LPOLECHAR or any other alias to 'unsigned char*'. This is the wide character format and therefore you need to convert your literal constant "ZIP4" to wide character format. That's why there is an 'L' infront of "ZIP4" in my example. 'L' makes the constant wide format. And finally the function wcscmp is the wide character version of strcmp, which compares two strings and returns 0 if they are equal.
0

Featured Post

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.

Question has a verified solution.

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

  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 …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

718 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