[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

compare CString

Carl Forsman

11/17/2008 3:15:00 AM

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;
}

3 Answers

Ian Collins

11/17/2008 3:17:00 AM

0

Carl Forsman wrote:
> how to compare a CString?
>
Try a windows group, CString isn't standard C++.

--
Ian Collins

Salt_Peter

11/17/2008 9:52:00 AM

0

On Nov 16, 10:14 pm, Carl Forsman <fatwallet...@yahoo.com> 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
}

David Connet

11/17/2008 3:32:00 PM

0

Salt_Peter <pj_hern@yahoo.com> wrote in news:f28eec71-822f-4894-9332-
d7fb8dddf8ae@k24g2000pri.googlegroups.com:

> On Nov 16, 10:14 pm, Carl Forsman <fatwallet...@yahoo.com> 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