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

NAME

6       strnlen - determine the length of a fixed-size string
7

SYNOPSIS

9       #include <string.h>
10
11       size_t strnlen(const char *s, size_t maxlen);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       strnlen():
16           Since glibc 2.10:
17               _POSIX_C_SOURCE >= 200809L
18           Before glibc 2.10:
19               _GNU_SOURCE
20

DESCRIPTION

22       The  strnlen()  function  returns  the  number  of  bytes in the string
23       pointed to by s, excluding the terminating null  byte  ('\0'),  but  at
24       most  maxlen.   In doing this, strnlen() looks only at the first maxlen
25       characters in the string pointed to by s and never beyond s[maxlen-1].
26

RETURN VALUE

28       The strnlen() function returns strlen(s), if that is less than  maxlen,
29       or maxlen if there is no null terminating ('\0') among the first maxlen
30       characters pointed to by s.
31

ATTRIBUTES

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

CONFORMING TO

43       POSIX.1-2008.
44

SEE ALSO

46       strlen(3)
47

COLOPHON

49       This  page  is  part of release 5.12 of the Linux man-pages project.  A
50       description of the project, information about reporting bugs,  and  the
51       latest     version     of     this    page,    can    be    found    at
52       https://www.kernel.org/doc/man-pages/.
53
54
55
56GNU                               2021-03-22                        STRNLEN(3)
Impressum