1strnlen(3)                 Library Functions Manual                 strnlen(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ATTRIBUTES

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

STANDARDS

46       POSIX.1-2008.
47

HISTORY

49       POSIX.1-2008.
50

SEE ALSO

52       strlen(3)
53
54
55
56Linux man-pages 6.05              2023-07-20                        strnlen(3)
Impressum