Home
       strtok.3 - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       strtok.3 (1900B)
       ---
            1 .TH strtok 3
            2 .SH NAME
            3 strtok - split 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, called in sequence,
           12 breaks the string pointed to by
           13 .I s1
           14 into a sequence of tokens,
           15 each of which is delimited by a character
           16 from the string pointed to by
           17 .IR s2 .
           18 .PP
           19 The first call in the sequence has a non-null first argument;
           20 subsequent calls in the sequence have a null first argument.
           21 .PP
           22 The separator string pointed to by
           23 .I s2
           24 may be different from call to call.
           25 .PP
           26 The first call in the sequence
           27 searches the string pointed to by
           28 .I s1
           29 for the first character
           30 that is not contained in the current separator
           31 string pointed to by
           32 .IR s2 .
           33 If no such character is found,
           34 then there are
           35 no tokens in the string pointed to by s1
           36 and the strtok function returns a null pointer.
           37 If such a character is found,
           38 it is the start of the first token.
           39 .PP
           40 The strtok function then searches from there
           41 for a character that is contained
           42 in the current separator string.
           43 If no such character is found,
           44 the current token extends to
           45 the end of the string pointed to by
           46 .IR s1 ,
           47 and subsequent searches for a token will return a null pointer.
           48 If such a character is found,
           49 it is overwritten by a null character,
           50 which terminates the current token.
           51 The strtok function saves
           52 a pointer to the following character,
           53 from which the next search for a token will start.
           54 .PP
           55 Each subsequent call,
           56 with a null pointer as the value of the first argument,
           57 starts searching from the saved pointer
           58 and behaves as described above.
           59 The function returns a pointer to the first
           60 character of a token,
           61 or a null pointer if there is no token.
           62 .SH RETURN VALUE
           63 The
           64 .BR strtok ()
           65 function shall return a pointer to the first character of a token,
           66 or a null pointer if there is no token.
           67 .SH STANDARDS
           68 ISO/IEC 9899:1999 Section 7.21.5.8