home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff218.lzh / EdLib / man / StrTok < prev    next >
Text File  |  1989-06-04  |  2KB  |  57 lines

  1. STRTOK(3)                  Library Functions                 STRTOK(3)
  2.  
  3.  
  4.  
  5. NAME
  6.      strtok - search a string for tokens delimited by characters
  7.      from a set
  8.  
  9. SYNOPSIS
  10.      #include <edlib.h>
  11.  
  12.      char *strtok(buf, separators)
  13.      char *buf, *separators;
  14.  
  15. DESCRIPTION
  16.      Strtok searches the null terminated string 'buf' for tokens
  17.      delimited by characters from the character set 'separators'.
  18.      The null terminated string 'separators' is treated as a set.
  19.      Thus, repetition and order are ignored. Strtok replaces the
  20.      separator character with a null byte and returns a pointer to
  21.      the beginning of the token, effectively singling out the first
  22.      token. Subsequent calls to strtok with the parameter 'buf' set
  23.      to NULL returns the next token after the previous one using the
  24.      same string as previous invocations. The character set
  25.      'separators' may be different at each invocation.
  26.  
  27. DIAGNOSTICS
  28.      If no token is found, a NULL pointer is returned.
  29.  
  30. EXAMPLE
  31.      Here is an example program demonstrating strtok(3).
  32.  
  33.      #include <stdio.h>
  34.  
  35.      extern char *strtok();
  36.      char tokesep[] = " \n\t\rx";
  37.  
  38.      main()
  39.      {
  40.              char buf[BUFSIZ], *tokep;
  41.  
  42.              while (fgets(buf, sizeof(buf), stdin)) {
  43.                      tokep = strtok(buf, tokesep);
  44.                      do {
  45.                              printf("Token is %s\n", tokep);
  46.                              tokep = strtok((char *)NULL, tokesep);
  47.                      }while (tokep);
  48.              }
  49.      }
  50.  
  51. AUTHOR
  52.      Daniel J. Barrett.
  53.      barrett@cs.jhu.edu or ins_adjb@jhunix.UUCP
  54.  
  55.  
  56.  
  57.