home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dec92.zip / 1012018D < prev    next >
Text File  |  1992-10-06  |  497b  |  25 lines

  1. /* strtok function */
  2. #include <string.h>
  3.  
  4. char *(strtok)(char *s1, const char *s2)
  5.     {    /* find next token in s1[] delimited by s2[] */
  6.     char *sbegin, *send;
  7.     static char *ssave = "";    /* for safety */
  8.  
  9.     sbegin = s1 ? s1 : ssave;
  10.     sbegin += strspn(sbegin, s2);
  11.     if (*sbegin == '\0')
  12.         {    /* end of scan */
  13.         ssave = "";                /* for safety */
  14.         return (NULL);
  15.         }
  16.     send = sbegin + strcspn(sbegin, s2);
  17.     if (*send != '\0')
  18.         *send++ = '\0';
  19.     ssave = send;
  20.     return (sbegin);
  21.     }
  22.  
  23.  
  24.  
  25.