Lstrtok_r

Breaks a string into a sequence of tokens, each of which is delimited by a character from another string.

Library:LibC
Classification:Other
Service:Characters and Strings

Syntax

  #include <string.h> 
   
  char *Lstrtok_r (
     char         *s1,
     const char   *s2,
     char        **s3);
  

Parameters

s1

(IN) Points to the string to break into a sequence of tokens.

s2

(IN) Points to the string containing the delimiter characters.

s3

(IN/OUT) Points to a value used to record the progress through s1.

Return Values

If a delimiter is found, returns a pointer to the first byte of a token. On subsequent iterations, if no delimiter is found, returns a NULL pointer.

If s1 does not contain any of the delimiters specified in s2, returns a pointer to s1, and all of s1 is considered to be a token.

Remarks

The Lstrtok_r function is a double-byte character interface. It is used to break the string pointed to by s1 into a sequence of tokens, each of which is delimited by a character from the string pointed to by s2.

The first call to Lstrtok_r returns a pointer to the first character of the first token in the string parameter and writes a NULL character into the string parameter immediately following the returned token. On subsequent calls, the string parameter must be set to NULL, and Lstrtok_r uses the value in the s3 parameter to search through the string and return successive tokens.

Because the Lstrtok_r function can modify the string by writing a NULL character to terminate a token, the string should be duplicated if the string is to be reused.

The Lstrtok_r function corresponds to the strtok_r function.

See Also