1strspn(3) Library Functions Manual strspn(3)
2
3
4
6 strspn, strcspn - get length of a prefix substring
7
9 Standard C library (libc, -lc)
10
12 #include <string.h>
13
14 size_t strspn(const char *s, const char *accept);
15 size_t strcspn(const char *s, const char *reject);
16
18 The strspn() function calculates the length (in bytes) of the initial
19 segment of s which consists entirely of bytes in accept.
20
21 The strcspn() function calculates the length of the initial segment of
22 s which consists entirely of bytes not in reject.
23
25 The strspn() function returns the number of bytes in the initial seg‐
26 ment of s which consist only of bytes from accept.
27
28 The strcspn() function returns the number of bytes in the initial seg‐
29 ment of s which are not in the string reject.
30
32 For an explanation of the terms used in this section, see at‐
33 tributes(7).
34
35 ┌────────────────────────────────────────────┬───────────────┬─────────┐
36 │Interface │ Attribute │ Value │
37 ├────────────────────────────────────────────┼───────────────┼─────────┤
38 │strspn(), strcspn() │ Thread safety │ MT-Safe │
39 └────────────────────────────────────────────┴───────────────┴─────────┘
40
42 C11, POSIX.1-2008.
43
45 POSIX.1-2001, C89, SVr4, 4.3BSD.
46
48 memchr(3), strchr(3), string(3), strpbrk(3), strsep(3), strstr(3), str‐
49 tok(3), wcscspn(3), wcsspn(3)
50
51
52
53Linux man-pages 6.04 2023-03-30 strspn(3)