home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_10_12
/
1012018d
< prev
next >
Wrap
Text File
|
1992-10-06
|
497b
|
25 lines
/* strtok function */
#include <string.h>
char *(strtok)(char *s1, const char *s2)
{ /* find next token in s1[] delimited by s2[] */
char *sbegin, *send;
static char *ssave = ""; /* for safety */
sbegin = s1 ? s1 : ssave;
sbegin += strspn(sbegin, s2);
if (*sbegin == '\0')
{ /* end of scan */
ssave = ""; /* for safety */
return (NULL);
}
send = sbegin + strcspn(sbegin, s2);
if (*send != '\0')
*send++ = '\0';
ssave = send;
return (sbegin);
}