1strnlen(3) Library Functions Manual strnlen(3)
2
3
4
6 strnlen - determine the length of a fixed-size string
7
9 Standard C library (libc, -lc)
10
12 #include <string.h>
13
14 size_t strnlen(const char s[.maxlen], size_t maxlen);
15
16 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18 strnlen():
19 Since glibc 2.10:
20 _POSIX_C_SOURCE >= 200809L
21 Before glibc 2.10:
22 _GNU_SOURCE
23
25 The strnlen() function returns the number of bytes in the string
26 pointed to by s, excluding the terminating null byte ('\0'), but at
27 most maxlen. In doing this, strnlen() looks only at the first maxlen
28 characters in the string pointed to by s and never beyond s[maxlen-1].
29
31 The strnlen() function returns strlen(s), if that is less than maxlen,
32 or maxlen if there is no null terminating ('\0') among the first maxlen
33 characters pointed to by s.
34
36 For an explanation of the terms used in this section, see at‐
37 tributes(7).
38
39 ┌────────────────────────────────────────────┬───────────────┬─────────┐
40 │Interface │ Attribute │ Value │
41 ├────────────────────────────────────────────┼───────────────┼─────────┤
42 │strnlen() │ Thread safety │ MT-Safe │
43 └────────────────────────────────────────────┴───────────────┴─────────┘
44
46 POSIX.1-2008.
47
49 POSIX.1-2008.
50
52 strlen(3)
53
54
55
56Linux man-pages 6.04 2023-03-30 strnlen(3)