Sender: nate AT cartsys DOT com Message-ID: <377FDD3D.A40E4675@cartsys.com> Date: Sun, 04 Jul 1999 15:16:29 -0700 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.10 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Newbie problems... Whats wrong with this code? References: <931066419 DOT 823 DOT 65 AT news DOT remarQ DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Al Morgan wrote: > The function you need in strcmp(char *str1, char *str2); It returns 0 if > both strings are equal (counter intuitive, isn't it?). I find it helps to think of it as subtraction. i.e. strcmp(s1, s2) <=> (s1 - s2). This also helps keep straight the meaning of the sign of the result (which one is greater), in the rare instances where one cares. I personally prefer to write `if (strcmp(s1, s2) == 0) ...' instead of `if (!strcmp(s1, s2))' for this reason, since it helps me think of strcmp as an arithmetic rather than logical operation. Even though it is a few more bytes. -- Nate Eldredge nate AT cartsys DOT com