Path: utzoo!attcan!uunet!snorkelwacker!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!travis!brad From: brad@SSD.CSD.HARRIS.COM (Brad Appleton) Newsgroups: comp.lang.c Subject: Re: more on TRUE and FALSE (side-comment) Message-ID: <1010@travis.csd.harris.com> Date: 17 Sep 90 13:44:57 GMT References: <9@christmas.UUCP> Sender: news@travis.csd.harris.com Organization: Harris Computers Systems Division, Fort Lauderdale,FL Lines: 33 In article quan@sol.surv.utas.oz (Stephen Quan) writes: >Personally I hate 'writing' programs with : > > if (strcmp(name,"hippo")==0) .... > >I know 'strcmp(a,b)' is designed to return 3 types of value : >-ve : a comes before b. > 0 : a equals b. >+ve : a comes after b. > >but it drives me balmy (not completely balmy though!) all the same. > >Anyone got a cure? At the moment I'm trying DIET COKE! It may not be terribly readable, but i use: if ( !strcmp(s1, s2) ) { ... } To test for equality!! Ive also seen (but dont use) the following: #define strEQ(s1,s2) !strcmp(s1,s2) #define strNE(s1,s2) strcmp(s1,s2) #define strLT(s1,s2) ( strcmp(s1,s2) < 0 ) #define strGT(s1,s2) ( strcmp(s1,s2) > 0 ) (and similar stuff for strncmp too!) ______________________ "And miles to go before I sleep." ______________________ Brad Appleton brad@travis.ssd.csd.harris.com Harris Computer Systems ...!uunet!hcx1!brad Fort Lauderdale, FL USA ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~