f78
strtok
[get next token from a string]
SYNOPSIS #include <string.h> char *strtok(char *source, const char *delimiters) char *strtok_r(char *source, const char *delimiters, char **lasts)
DESCRIPTION
A series of calls to strtok
break the string starting at *source
into a sequence of tokens. The tokens are delimited from one another by
characters from the string at *delimiters,
at the outset. The first call to strtok
normally has a string address as the first argument; subsequent calls can
use NULL
as the first argument, to continue searching the same string. You can continue
searching a single string with different delimiters by using a different
delimiter string on each call.
strtok begins by searching for any character not in the delimiters string: the first such character is the beginning of a token (and its ad-dress will be the result of the strtok call). strtok then continues searching until it finds another delimiter character; it replaces that character by NULL and returns. (If strtok comes to the end of the *source string without finding any more delimiters, the entire remainder of the string is treated as the next token). strtok starts its search at *source, unless you pass NULL< 6de FONT FACE="Times New Roman"> as the first argument; if source is NULL, strtok continues searching from the end of the last search. Exploiting the NULL first argument leads to non-reentrant code. You can easily circumvent this problem by saving the last delimiter address in your application, and always using it to pass a non-null source argument.
RETURNS
strtok
returns a pointer to the next token, or NULL
if no more tokens can be found.
COMPLIANCE
strtok
is ANSI C.
strtok requires no supporting OS subroutines.
0