Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!att!dptg!ulysses!andante!alice!ark From: ark@alice.att.com (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: Comparing strings... Message-ID: <11486@alice.att.com> Date: 14 Oct 90 13:38:05 GMT References: <1990Oct13.190106.15615@ux1.cso.uiuc.edu> <3330@idunno.Princeton.EDU> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 15 In article <3330@idunno.Princeton.EDU>, pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes: > int strcmp(char *s,char *t) > { > for (; *s && *s == *t; s++,t++); > return *s-*t; > } Whether or not this works depends on your definition of the problem. If you really want to follow the normal lexical convention that the null string compares <= anything else, and you're on a machine on which chars can be negative, then it doesn't work. -- --Andrew Koenig ark@europa.att.com