Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stan!imp From: imp@solbourne.com (Warner Losh) Newsgroups: alt.hackers Subject: Re: Useful string function Message-ID: <1991Jun26.203655.29321@solbourne.com> Date: 26 Jun 91 20:36:55 GMT References: <27187@ttidca.TTI.COM> <1991Jun26.164123.6281@watson.ibm.com> Organization: Solbourne, User Interface Group Lines: 26 Approved: Sure thing luke. In article <1991Jun26.164123.6281@watson.ibm.com> pierce@watson.ibm.com () writes: >It may not be part of ANSI C, but every halfway respectable compiler >I've ever used has had a strstr() function that returns a pointer to >the substring. And the ones that didn't it was easy enough to write char *strstr (register char *str, register char *substr) { register int len = strlen (substr); for (str = strchr (str, *substr); str && strncmp (str, substr, len) != 0; str = strchr (str + 1, *substr)) continue; return str; } [[ This is typed from memory, so I may have a + 1 where I don't need it or lack one where I do ]] Warner -- Warner Losh imp@Solbourne.COM But it was our hill. And they were our beans.