strstr.c 457 B

12345678910111213141516171819
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #include <string.h>
  7. char *
  8. strstr(register const char *s, register const char *wanted)
  9. {
  10. register const int len = strlen(wanted);
  11. if (len == 0) return (char *)s;
  12. while (*s != *wanted || strncmp(s, wanted, len))
  13. if (*s++ == '\0')
  14. return (char *)NULL;
  15. return (char *)s;
  16. }