strtok

Find the next token in a string.

char * strtok (char * tokenstr, char * delimitstr);

Required Header
<string.h>

Return Value

A pointer to a token in string is returned. NULL is returned when there are no more tokens in the string.

Parameters

tokenstr

  A string

delimitstr

  A string containing a set of delimiter characters

Remarks

The strtok function skips leading delimiters on the first call, where the tokenstr value must be passed. On successive calls, tokenstr must be set to NULL which will allow the function to continue searching the initial string. tokenstr is modified for each call to strtok by adding a null-terminator character at the end of each token found.

The strtok function is thread-safe, but a single thread cannot scan two different tokenstr strings at the same time due to a static character pointer used internally by the routine.

delimitstr may be varied as required on successive calls to strtok.

String

See Also    strcspn, strspn, _strspnp