home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / c / sozobon-v2 / dlibsrc.lha / STRTOK.C < prev    next >
C/C++ Source or Header  |  1988-10-05  |  497b  |  25 lines

  1. #include <stddef.h>
  2.  
  3. static    char    *_strtok = NULL;    /* local token pointer */
  4.  
  5. char *strtok(string, delim)
  6.     register char *string, *delim;
  7.     {
  8.     register char *p;
  9.     char *strchr();
  10.  
  11.     if(string == NULL)
  12.         string = _strtok;
  13.     while(*string && strchr(delim, *string))
  14.         ++string;
  15.     if(*string == '\0')        /* no more tokens */
  16.         return(NULL);
  17.     p = string;
  18.     while(*string && !strchr(delim, *string))
  19.         ++string;
  20.     if(*string != '\0')
  21.         *string++ = '\0';
  22.     _strtok = string;
  23.     return(p);
  24.     }
  25.