1STRSEP(3)                  Linux Programmer's Manual                 STRSEP(3)
2
3
4

NAME

6       strsep - extract token from string
7

SYNOPSIS

9       #include <string.h>
10
11       char *strsep(char **stringp, const char *delim);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       strsep(): _BSD_SOURCE
16

DESCRIPTION

18       If  *stringp is NULL, the strsep() function returns NULL and does noth‐
19       ing else.  Otherwise, this function finds the first token in the string
20       *stringp,  where  tokens  are delimited by symbols in the string delim.
21       This token is terminated by overwriting the delimiter with a null  byte
22       ('\0')  and  *stringp  is  updated to point past the token.  In case no
23       delimiter was found, the  token  is  taken  to  be  the  entire  string
24       *stringp, and *stringp is made NULL.
25

RETURN VALUE

27       The  strsep()  function  returns  a  pointer  to the token, that is, it
28       returns the original value of *stringp.
29

CONFORMING TO

31       4.4BSD.
32

NOTES

34       The strsep() function was introduced as a  replacement  for  strtok(3),
35       since  the  latter cannot handle empty fields.  However, strtok(3) con‐
36       forms to C89/C99 and hence is more portable.
37

BUGS

39       Be cautious when using this function.  If you do use it, note that:
40
41       * This function modifies its first argument.
42
43       * This function cannot be used on constant strings.
44
45       * The identity of the delimiting character is lost.
46

SEE ALSO

48       index(3), memchr(3), rindex(3), strchr(3), string(3), strpbrk(3),  str‐
49       spn(3), strstr(3), strtok(3)
50

COLOPHON

52       This  page  is  part of release 3.53 of the Linux man-pages project.  A
53       description of the project, and information about reporting  bugs,  can
54       be found at http://www.kernel.org/doc/man-pages/.
55
56
57
58GNU                               2011-09-28                         STRSEP(3)
Impressum