home *** CD-ROM | disk | FTP | other *** search
- STRTOK(3) Library Functions STRTOK(3)
-
-
-
- NAME
- strtok - search a string for tokens delimited by characters
- from a set
-
- SYNOPSIS
- #include <edlib.h>
-
- char *strtok(buf, separators)
- char *buf, *separators;
-
- DESCRIPTION
- Strtok searches the null terminated string 'buf' for tokens
- delimited by characters from the character set 'separators'.
- The null terminated string 'separators' is treated as a set.
- Thus, repetition and order are ignored. Strtok replaces the
- separator character with a null byte and returns a pointer to
- the beginning of the token, effectively singling out the first
- token. Subsequent calls to strtok with the parameter 'buf' set
- to NULL returns the next token after the previous one using the
- same string as previous invocations. The character set
- 'separators' may be different at each invocation.
-
- DIAGNOSTICS
- If no token is found, a NULL pointer is returned.
-
- EXAMPLE
- Here is an example program demonstrating strtok(3).
-
- #include <stdio.h>
-
- extern char *strtok();
- char tokesep[] = " \n\t\rx";
-
- main()
- {
- char buf[BUFSIZ], *tokep;
-
- while (fgets(buf, sizeof(buf), stdin)) {
- tokep = strtok(buf, tokesep);
- do {
- printf("Token is %s\n", tokep);
- tokep = strtok((char *)NULL, tokesep);
- }while (tokep);
- }
- }
-
- AUTHOR
- Daniel J. Barrett.
- barrett@cs.jhu.edu or ins_adjb@jhunix.UUCP
-
-
-
-