1STRSEP(3) Linux Programmer's Manual STRSEP(3)
2
3
4
6 strsep - extract token from string
7
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():
16 Since glibc 2.19:
17 _DEFAULT_SOURCE
18 Glibc 2.19 and earlier:
19 _BSD_SOURCE
20
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
31 The strsep() function returns a pointer to the token, that is, it
32 returns the original value of *stringp.
33
35 For an explanation of the terms used in this section, see
36 attributes(7).
37
38 ┌──────────┬───────────────┬─────────┐
39 │Interface │ Attribute │ Value │
40 ├──────────┼───────────────┼─────────┤
41 │strsep() │ Thread safety │ MT-Safe │
42 └──────────┴───────────────┴─────────┘
44 4.4BSD.
45
47 The strsep() function was introduced as a replacement for strtok(3),
48 since the latter cannot handle empty fields. However, strtok(3) con‐
49 forms to C89/C99 and hence is more portable.
50
52 Be cautious when using this function. If you do use it, note that:
53
54 * This function modifies its first argument.
55
56 * This function cannot be used on constant strings.
57
58 * The identity of the delimiting character is lost.
59
61 index(3), memchr(3), rindex(3), strchr(3), string(3), strpbrk(3), str‐
62 spn(3), strstr(3), strtok(3)
63
65 This page is part of release 5.07 of the Linux man-pages project. A
66 description of the project, information about reporting bugs, and the
67 latest version of this page, can be found at
68 https://www.kernel.org/doc/man-pages/.
69
70
71
72GNU 2019-03-06 STRSEP(3)