Re: passing a string to a dll

Tech-Archive recommends: Fix windows errors by optimizing your registry



However, if you don't trust CString::operator != to work, there's very little else about
C++ that can be trusted.

Note that the CString::Compare simply turns into wcscmp/strcmp, assuming those do what you
want. CString::Collate will be more locale-sensitive.
joe

On Tue, 18 Sep 2007 21:00:16 +0100, "David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:


"David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:lHVHi.50873$Um6.31878@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

if(s != _T("12345") )
...

if( s.Compare( _T("12345") ) )

Ah, but you would really need:

if( s.Compare( _T("12345") == 0 ) )

No. Compare() returns non-zero if the strings differ - like strcmp().

if (s != _T("12345") )
which illustrates the intent perfectly.

I agree it looks nicer. But as I say it leaves me a little nervous, if
irrationally so. [Not *that* irrational, otherwise the OP wouldn't have had
a problem!]

But I don't go for all that ==0 stuff. I was using C long enough to get
used to writing

if( n )

for any integer type. Similarly I never write if( p!=NULL ) for pointers
but just if(p). And things like

TCHAR *psz;
...
if( psz && *psz ) ....

The idiom is now so familiar that I no longer feel the need for my usual
degree of pedantry :-)

Dave
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Diabetes blood glucose readers?
    ... the Aussie salute between bites. ... Trust me - testing is nicer than being bitten:) ...
    (alt.support.diabetes)
  • Re: [opensuse] LVM
    ... flexibility is so much nicer. ... I can't say I don't trust it, nor can I say I can, as I've given it little ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ...
    (SuSE)
  • Re: [opensuse] LVM
    ... flexibility is so much nicer. ... I don't trust it. ... I forgot to say: it is not cross-platform. ...
    (SuSE)
  • Re: A Few Ways To Listen To Your Horse
    ... of the real crazies that used to sidle in here. ... Trust me. ... The wreck ... is a nicer place than it used to be. ...
    (rec.equestrian)