scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

strtok.3 (1534B)


      1 .TH strtok 3
      2 .SH NAME
      3 strtok - break a string into tokens
      4 .SH SYNOPSIS
      5 #include <string.h>
      6 
      7 char *strtok(char *restrict s1, const char *restrict s2)
      8 .SH DESCRIPTION
      9 The
     10 .BR strtok ()
     11 function splits the string at
     12 .I s1
     13 into a series of tokens, each bounded by one or more delimiter characters
     14 drawn from the string at
     15 .IR s2 .
     16 It is called repeatedly to extract successive tokens.
     17 .PP
     18 The first call must pass the string to tokenize as
     19 .IR s1 ;
     20 subsequent calls must pass NULL as
     21 .I s1
     22 to continue where the previous call left off.
     23 .PP
     24 The delimiter set in
     25 .I s2
     26 may differ between calls.
     27 .PP
     28 On each call, the function advances past any leading delimiter characters,
     29 then locates the next delimiter in the remainder of the string.
     30 If no non-delimiter character is found, no tokens remain
     31 and a null pointer is returned.
     32 Otherwise, that character marks the start of a new token.
     33 .PP
     34 When the end of the token is found,
     35 it is terminated by overwriting the delimiter character with a null byte.
     36 A pointer to the next character is saved internally
     37 and used as the starting point for the following call.
     38 If no delimiter follows the token,
     39 subsequent calls will return a null pointer.
     40 .PP
     41 After the first call, each subsequent call with NULL as
     42 .I s1
     43 resumes scanning from the saved position,
     44 applying the same logic described above.
     45 .SH RETURN VALUE
     46 The
     47 .BR strtok ()
     48 function returns a pointer to the first character of the current token,
     49 or a null pointer when no more tokens are found.
     50 .SH STANDARDS
     51 ISO/IEC 9899:1999 Section 7.21.5.8