Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: more on TRUE and FALSE (side-comment) Message-ID: <1990Sep18.163533.16008@zoo.toronto.edu> Organization: U of Toronto Zoology References: <9@christmas.UUCP> Date: Tue, 18 Sep 90 16:35:33 GMT In article quan@sol.surv.utas.oz (Stephen Quan) writes: >Personally I hate 'writing' programs with : > > if (strcmp(name,"hippo")==0) .... Agreed. This is a *very* confusing convention, made all the worse by pinheads who shorten it to `if (strcmp(a, b))' or `if (!strcmp(a, b))' without considering what a nuisance this is to readers. Our local custom is to define a STREQ macro; the inequality comparisons are much less troublesome (and much rarer) and don't really need the help. My current favorite definition is: #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) Note that this is an unsafe macro; on the other hand, it is typically much faster than one which just calls strcmp every time. Most string comparisons fail on the first character. -- TCP/IP: handling tomorrow's loads today| Henry Spencer at U of Toronto Zoology OSI: handling yesterday's loads someday| henry@zoo.toronto.edu utzoo!henry