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 **restrict stringp, const char *restrict delim);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       strsep():
16           Since glibc 2.19:
17               _DEFAULT_SOURCE
18           Glibc 2.19 and earlier:
19               _BSD_SOURCE
20

DESCRIPTION

22       If  *stringp is NULL, the strsep() function returns NULL and does noth‐
23       ing else.  Otherwise, this function finds the first token in the string
24       *stringp,  that  is  delimited by one of the bytes in the string delim.
25       This token is terminated by overwriting the delimiter with a null  byte
26       ('\0'),  and  *stringp  is updated to point past the token.  In case no
27       delimiter was found, the  token  is  taken  to  be  the  entire  string
28       *stringp, and *stringp is made NULL.
29

RETURN VALUE

31       The  strsep()  function returns a pointer to the token, that is, it re‐
32       turns the original value of *stringp.
33

ATTRIBUTES

35       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
36       tributes(7).
37
38       ┌────────────────────────────────────────────┬───────────────┬─────────┐
39Interface                                   Attribute     Value   
40       ├────────────────────────────────────────────┼───────────────┼─────────┤
41strsep()                                    │ Thread safety │ MT-Safe │
42       └────────────────────────────────────────────┴───────────────┴─────────┘
43

CONFORMING TO

45       4.4BSD.
46

NOTES

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

BUGS

53       Be cautious when using this function.  If you do use it, note that:
54
55       * This function modifies its first argument.
56
57       * This function cannot be used on constant strings.
58
59       * The identity of the delimiting character is lost.
60

SEE ALSO

62       index(3),  memchr(3), rindex(3), strchr(3), string(3), strpbrk(3), str‐
63       spn(3), strstr(3), strtok(3)
64

COLOPHON

66       This page is part of release 5.13 of the Linux  man-pages  project.   A
67       description  of  the project, information about reporting bugs, and the
68       latest    version    of    this    page,    can     be     found     at
69       https://www.kernel.org/doc/man-pages/.
70
71
72
73GNU                               2021-03-22                         STRSEP(3)
Impressum