Comparing strings...
Henry Spencer
henry at zoo.toronto.edu
Mon Oct 15 14:28:51 AEST 1990
In article <3343 at idunno.Princeton.EDU> pfalstad at 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 at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list