Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > compare CString

Reply
Thread Tools

compare CString

 
 
Carl Forsman
Guest
Posts: n/a
 
      11-17-2008
how to compare a CString?

the following does not seem to work.

CString id = PictureEntries[i].attribute("id").value();

if (id.Compare("2222") == 1){
cout << id << endl;
}

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      11-17-2008
Carl Forsman wrote:
> how to compare a CString?
>

Try a windows group, CString isn't standard C++.

--
Ian Collins
 
Reply With Quote
 
 
 
 
Salt_Peter
Guest
Posts: n/a
 
      11-17-2008
On Nov 16, 10:14 pm, Carl Forsman <(E-Mail Removed)> wrote:
> how to compare a CString?
>
> the following does not seem to work.
>
> CString id = PictureEntries[i].attribute("id").value();
>
> if (id.Compare("2222") == 1){
> cout << id << endl;
> }


Whats a CString?

As a hint: what is the difference between a null terminated sequence
of characters and one that isn't null terminated? The point here is
that if you don't know or aren't sure, use a little brain power:

CString id("abcdef")
if( id.Compare( CString("abcdef") )
{
// do stuff
}

 
Reply With Quote
 
David Connet
Guest
Posts: n/a
 
      11-17-2008
Salt_Peter <(E-Mail Removed)> wrote in news:f28eec71-822f-4894-9332-
http://www.velocityreviews.com/forums/(E-Mail Removed):

> On Nov 16, 10:14 pm, Carl Forsman <(E-Mail Removed)> wrote:
>> how to compare a CString?
>>
>> the following does not seem to work.
>>
>> CString id = PictureEntries[i].attribute("id").value();
>>
>> if (id.Compare("2222") == 1){
>> cout << id << endl;
>> }

>
> Whats a CString?
>
> As a hint: what is the difference between a null terminated sequence
> of characters and one that isn't null terminated? The point here is
> that if you don't know or aren't sure, use a little brain power:
>
> CString id("abcdef")
> if( id.Compare( CString("abcdef") )
> {
> // do stuff
> }


Which is why you shouldn't ask CString questions here! The above is
wrong.

if (0 == id.Compare("abcdef"))
{
// do stuff
}

or

if (id == "abcdef")
{
}

The OP also asked in an MS group and "learned" how to make the proper
call. Though the term RTFM was missing in those posts.

Dave Connet
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML transcode - CString to XMLCh eagle_speaks@yahoo.co.uk XML 0 08-16-2005 10:12 AM
Parsing char array to CString John Smith C++ 4 09-09-2003 12:20 PM
? CString to char* in Unicode; How to convert? Markus Hämmerli C++ 6 09-04-2003 08:31 PM
Why is CString not preferred Rajesh Garg C++ 11 07-24-2003 03:33 PM
I hate cstring!!! yeye yaya C++ 7 07-11-2003 09:33 PM



Advertisments