Debian Codegraph @

upstream/debian-unstable/man3/strlen.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH strlen 3 2026-02-25 "Linux man-pages 6.18"
8 .SH NAME
9 strlen \- calculate the length of a string
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <string.h>
16 .P
17 .BI "size_t strlen(const char *" s );
18 .fi
19 .SH DESCRIPTION
20 The
21 .BR strlen ()
22 function calculates the length of the string pointed to by
23 .IR s ,
24 excluding the terminating null byte (\[aq]\[rs]0\[aq]).
25 .P
26 It is equivalent to
27 .P
28 .in +4n
29 .EX
30 strnul(s) - s
31 .EE
32 .in
33 .SH RETURN VALUE
34 The
35 .BR strlen ()
36 function returns the number of bytes in the string pointed to by
37 .IR s .
38 .SH ATTRIBUTES
39 For an explanation of the terms used in this section, see
40 .BR attributes (7).
41 .TS
42 allbox;
43 lbx lb lb
44 l l l.
45 Interface Attribute Value
46 T{
47 .na
48 .nh
49 .BR strlen ()
50 T} Thread safety MT-Safe
51 .TE
52 .SH STANDARDS
53 C11, POSIX.1-2008.
54 .SH HISTORY
55 POSIX.1-2001, C89, SVr4, 4.3BSD.
56 .SH NOTES
57 In cases where the input buffer may not contain
58 a terminating null byte,
59 .BR strnlen (3)
60 should be used instead.
61 .SH SEE ALSO
62 .BR string (3),
63 .BR strnlen (3),
64 .BR strnul (3),
65 .BR wcslen (3),
66 .BR wcsnlen (3)