On Wed, Jun 04, 2008 at 08:30:48PM +0100, Philip Martin wrote:
> To my eye strcmp() == 0 is as ugly as the construct 5 == x; I find
> !strcmp() is as natural as !ptr. entries.c used both strcmp styles
> and ! form was dominant so at least one other developer must agree
> with me. I realise styles change; years ago when I started writing C
> the people I worked with would only ever have written strcmp() == 0 if
> it was mixed with strcmp() > 0 or strcmp() < 0.
In my mind, ! is a boolean operator, and strcmp() does not return
a boolean value:
The strcmp() and strncmp() return an integer greater than, equal to, or
less than 0, according as the string s1 is greater than, equal to, or
less than the string s2.
For pointers, ! makes sense -- the pointer is either valid or it isn't.
> Writing strcmp() == 0
> on it's own it would probably have attracted comments referring to
> Pascal, or Modula2, and the subsequent debate would inevitably include
> "of course a real programmer would use FORTRAN".
Heh. When I started programming, many people had already forgotten
that these languages ever existed :)
Received on 2008-06-04 22:06:29 CEST
- application/pgp-signature attachment: stored