By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,491 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,491 IT Pros & Developers. It's quick & easy.

compare CString

P: n/a
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;
}

Nov 17 '08 #1
Share this Question
Share on Google+
3 Replies


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

--
Ian Collins
Nov 17 '08 #2

P: n/a
On Nov 16, 10:14 pm, Carl Forsman <fatwallet...@yahoo.comwrote:
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
}

Nov 17 '08 #3

P: n/a
Salt_Peter <pj*****@yahoo.comwrote in news:f28eec71-822f-4894-9332-
d7**********@k24g2000pri.googlegroups.com:
On Nov 16, 10:14 pm, Carl Forsman <fatwallet...@yahoo.comwrote:
>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
Nov 17 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.