home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cproto.zip
/
cproto46
/
strstr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-12
|
601b
|
33 lines
/* $Id: strstr.c,v 4.1 1994/10/12 14:12:48 cthuang Exp $
*
* Simple implementation of the ANSI strstr() function
*/
#include <stdio.h>
#include "cproto.h"
/* Search for a substring within the given string.
* Return a pointer to the first occurence within the string,
* or NULL if not found.
*/
#if !HAVE_STRSTR
char *
strstr (src, key)
char *src, *key;
{
char *s;
int keylen;
if ((keylen = strlen(key)) == 0)
return src;
s = strchr(src, *key);
while (s != NULL) {
if (strncmp(s, key, keylen) == 0)
return s;
s = strchr(s+1, *key);
}
return NULL;
}
#endif