home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume13
/
korner
/
strtok.c
< prev
Wrap
C/C++ Source or Header
|
1988-01-31
|
728b
|
53 lines
#include <stdio.h>
static char *Save=NULL;
char *
strtok(str,delim)
char *str, *delim;
{
char *tokstart, *tokend, *first_ch (), *last_ch();
if (str != NULL)
Save = str;
if (Save == NULL)
return (NULL);
tokstart = first_ch (Save, delim);
tokend = last_ch (tokstart, delim);
Save = first_ch (tokend, delim);
*tokend = '\0';
if (*tokstart == '\0')
return (NULL);
return (tokstart);
}
static char *
first_ch (str,delim)
char *str,*delim;
{
char *index ();
char *f;
for (f = str; *f != '\0' && index(delim,*f) != NULL; ++f)
;
return (f);
}
static char *
last_ch (str,delim)
char *str,*delim;
{
char *index ();
char *f;
for (f = str; *f != '\0' && index(delim,*f) == NULL; ++f)
;
return (f);
}