home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
187_01
/
sub_str.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-12-31
|
1KB
|
40 lines
/*@*****************************************************/
/*@ */
/*@ sub_str - search a string for a given substring. */
/*@ Uses INDEX to find occurance of first */
/*@ char of substring, then STRCMP to check */
/*@ the rest for a match. */
/*@ */
/*@ Usage: sub_str(search, find); */
/*@ where search is the string to search. */
/*@ find is the substring for which to */
/*@ search. */
/*@ */
/*@ Returns TRUE if the substring is found, */
/*@ FALSE otherwise. */
/*@ */
/*@*****************************************************/
#define TRUE 1
#define FALSE 0
int sub_str(ss, sf)
char *ss, *sf;
{
int len;
char *index(), *k;
len = strlen(sf);
k = ss;
while (k) {
if (k = index(k, *sf))
if (!strncmp(k, sf, len))
return TRUE;
else
k++;
}
return FALSE;
}