compare CString

C

Carl Forsman

how to compare a CString?

the following does not seem to work.

CString id = PictureEntries.attribute("id").value();

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

Salt_Peter

how to compare a CString?

the following does not seem to work.

CString id = PictureEntries.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
}
 
D

David Connet

how to compare a CString?

the following does not seem to work.

CString id = PictureEntries.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top