Re: passing a string to a dll
Hi David,
I agree, and I missed the first part. However, the Compare() function does
follow the time-honored = 0 (compares) < 0 string is less than, or > 0
string is great than. The use for that is mostly for sorting. I do think
it is confusing and that most people just check for == 0 or != 0.
Fortunately, in C, == means equivalence, not a numeric equal or assignment
so it should not be confusing to use "==". But, as said, the good news is
we can all do it how we like :o)
Tom
"David Ching" <dc@remove-this.dcsoft.com> wrote in message
news:681Ii.27827$eY.11716@newssvr13.news.prodigy.net...
"Tom Serface" <tom.nospam@camaswood.com> wrote in message
news:%23ZyxQwj%23HHA.748@TK2MSFTNGP04.phx.gbl...
Yeah, but writing
if(!s.Compare(_T("12345"))
is even more confusing than
if(s.Compare(_T("12345")) == 0)
I think == and Compare evaluate to the same code, but CompareNoCase() is
definitely useful. I wish there were a FindNoCase() equivalent.
Well, my point is David We. inadvertently got it wrong by saying
if (s.Compare(_T("12345")) ) was the same as
if (s == (_T("12345"))
when in fact they mean the opposite,
and to use the Compare() method, you actually have to say "!s.Compare()"
or else say "== 0" which illustrates how confusing is the stupid C
convention of having something equal to 0 actually means it is true.
Using CString::operator == nicely gets around all of that.
-- David