Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!mcsun!ukc!stl!robobar!ronald From: ronald@robobar.co.uk (Ronald S H Khoo) Newsgroups: comp.lang.c Subject: Re: "str*cmp()" ain't Boolean (was Re: v18i058: mush - Mail User's Shell, Part01/22) Message-ID: <1991May4.135640.22311@robobar.co.uk> Date: 4 May 91 13:56:40 GMT References: <20523@ogicse.ogi.edu> <1991May1.181910.28750@robobar.co.uk> <7609@auspex.auspex.com> Organization: Robobar Ltd., Perivale, Middx., ENGLAND. Lines: 18 guy@auspex.auspex.com (Guy Harris) writes: > >> 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 "=="? I must admit that the !strncmp() construct which appears all over the code is one of the things that I find very hard to follow. If I need to understand a piece of the code, I tend to rewrite it as == 0 first before looking at it :-). But, it's *their* code, which I'm grateful for, so I ain't going to complain about it. Guy's right that I can't read !strcmp, but I wasn't actually complaining about it, just noting that I had seen or copied it wrong originally. -- Ronald Khoo +44 81 991 1142 (O) +44 71 229 7741 (H)