Re: passing a string to a dll

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



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.

Tom

"David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:%23HnKe%23i%23HHA.5160@xxxxxxxxxxxxxxxxxxxxxxx

"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
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm






.



Relevant Pages

  • Re: "Shalom in the Home"
    ... Mathematics, and Writing. ... be recentered to compare to 1995 to present scores by using official ... Verbal and 20 or 30 points to Math. ... In other words, current students ...
    (soc.culture.jewish.moderated)
  • Re: It is impossible for any woman or man to accept Shoghi Effendis Guardianship without accepting t
    ... >> Perhaps you could indicate the criteria by which you would compare and ... photographic enlargements are the mode of formation of the writing, ... in the writing of the writer of the authenticated signature." ... the writing of Abdul Baha, as shown in the authenticated specimens." ...
    (talk.religion.bahai)
  • Re: Why use assembly?
    ... compare func is something trivial such as: ... Writing such state machine in assembler doesn't give much benefit over ...
    (alt.lang.asm)
  • Happy Christmas and best wishes for the New YEar.
    ... perhaps we can extend the group and perhaps grow the group once more ... just begin to extend them and compare with those of other areas?? ... folk' that other authors have included in their writing? ... Australian Opinion ...
    (alt.fan.harry-potter)
  • Re: C or C++
    ... David Webber wrote: ... Most program use a combination of C++ code and calling C functions. ... way, and write good C++, you'll probably find writing C is tedious. ... an OO language, rather it is a multi-paradigm language that, among others, ...
    (microsoft.public.vc.language)