"str*cmp()" ain't Boolean (was Re: v18i058: mush - Mail User's Shell, Part01/22)

Guy Harris guy at auspex.auspex.com
Sat May 4 07:17:36 AEST 1991


 >> } >   if (show_to && strncmp(p, login, strlen(login)))
 >
 >> My copy says !strncmp(p, login, strlen(login)) ....
 >
 >Ooops.  Finger trouble.  So does mine.

Perhaps this is a hint that one shouldn't treat "strncmp()" as if it
were a Boolean function, and should instead compare its result with 0
explicitly, e.g. if you're comparing strings for equality, use "=="?



More information about the Comp.lang.c mailing list