Next: str_varscan, Previous: str_dtokcnt, Up: Strings
split a string into tokens.
#include <suplib/str.h>size_t str_dtoksplit( char *str, char *tok[], const char *delim, int ntok );
char *str
- the string to split up
char *tok[]
- the array to stick
const char *delim
- the delimiters to split on
int ntok
- the maximum number of tokens to read
This routine splits a string into a series of tokens. Unlike the
system library function strtok
, each instance of a delimiter
implies a token. In strtok
, sequential delimiters are
collapsed into one. This function allows one to have empty tokens.
It fills a caller provided array with pointers to the tokens. The
caller may specify a maximum number of tokens to read. Note that an
empty string corresponds to a single, empty, token.
The passed string is modified (end of string characters are inserted where necessary).
It returns the number of tokens read.
Diab Jerius