

strtok()                 String Function                 strtok()




Break a string into tokens

#include <string.h>
cchhaarr *ssttrrttookk(_s_t_r_i_n_g_1, _s_t_r_i_n_g_2);
cchhaarr *_s_t_r_i_n_g_1, *_s_t_r_i_n_g_2;

strtok helps  to divide a  string into a set  of tokens.  string1
points to  the string  to be divided,  and string2 points  to the
character or characters that delimit the tokens.

strtok divides a string into tokens by being called repeatedly.

On the  first call to strtok, string1 should  point to the string
being  divided.  strtok  searches  for a  character  that is  _n_o_t
included within string2.  If it finds one, then strtok regards it
as the  beginning of the  first token within the  string.  If one
cannot  be found,  then strtok  returns NULL  to signal  that the
string could  not be divided into tokens.   When the beginning of
the first token is found,  strtok then looks for a character that
_i_s included  within string2.  When one  is found, strtok replaces
it with  a null  character to  mark the end  of the  first token,
stores  a pointer  to the  remainder of  string1 within  a static
buffer, and  returns the  address of  the beginning of  the first
token.

On subsequent calls to  strtok, set string1 to NULL.  strtok then
looks for subsequent tokens, using the address that it saved from
the first call.  With each call to strtok, string2 may point to a
different delimiter or set of delimiters.

***** See Also *****

string functions, string.h























COHERENT Lexicon                                           Page 1


