Comparing strings...

Paul John Falstad pfalstad at phoenix.Princeton.EDU
Sun Oct 14 08:51:40 AEST 1990


In article <qDwZq1w161w at fozzie.pheonix.com> stanley at fozzie.pheonix.com (John Stanley) writes:
>gordon at osiris.cso.uiuc.edu (John Gordon) writes:
>> 	Hmmm... Well, here's what I came up with:
>   Did I miss something, or is everyone overlooking the library functions
>strcmp and strncmp that are already provided to do this?

You're not missing anything.  You're just the only one who bothered to
post the obvious.

Here's a better implementation of strcmp, by the way: (not that it
matters, since it's in the library)

int strcmp(char *s,char *t)
{
	for (; *s && *s == *t; s++,t++);
	return *s-*t;
}

--
pfalstad at phoenix.princeton.edu   The Germans are disputing it! Hegel is
arguing that the reality is merely an a priori adjunct of non-absolutistic
ethics; Kant, by the categorical imperative, is holding it ontologically
exists only in the imagination; and Marx is claiming it was off sides.



More information about the Comp.lang.c mailing list