Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Comparing strings...
Message-ID: <1990Oct15.042851.18595@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1990Oct13.190106.15615@ux1.cso.uiuc.edu> <3330@idunno.Princeton.EDU> <11486@alice.att.com> <3343@idunno.Princeton.EDU>
Date: Mon, 15 Oct 90 04:28:51 GMT

In article <3343@idunno.Princeton.EDU> pfalstad@drops.Princeton.EDU (Paul John Falstad) writes:
>	while((c = (unsigned char) *s++) == (d == (unsigned char) *t++) && c);

Uh-uh, you don't want to do the conversions inside the loop; they can add
significant expense, and are irrelevant to an equality comparison.  You
do the conversions -- and conversions *back* to int so the difference
is signed -- in the post-loop wrapup.

By the way, tacking the ";" on the end of the while is a great way to
trip up your readers, which is thought amusing by amateurs and is avoided
by professionals.
-- 
"...the i860 is a wonderful source     | Henry Spencer at U of Toronto Zoology
of thesis topics."    --Preston Briggs |  henry@zoo.toronto.edu   utzoo!henry
