home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / DLIBSSRC.ZIP / STRSTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-14  |  457 b   |  22 lines

  1. #include <d:\usr\stdlib\stdio.h>
  2.  
  3. char *strstr(string, pattern)
  4. register char *string;
  5. register char *pattern;
  6. /*
  7.  *    Return a pointer to the first occurance of <pattern> in <string>.
  8.  *    NULL is returned if <pattern> is not found.
  9.  */
  10. {
  11.     register int plen;
  12.     char *strchr();
  13.  
  14.     plen = strlen(pattern);
  15.     while(string = strchr(string, *pattern)) {
  16.         if(strncmp(string, pattern, plen) == 0)
  17.             return(string);
  18.         ++string;
  19.     }
  20.     return(NULL);
  21. }
  22.