Debian Codegraph @

upstream/debian-unstable/man3/strchr.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 strchr 3 2026-02-25 "Linux man-pages 6.18"
8 .SH NAME
9 strchr, strrchr \- locate character in 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 "char *strchr(const char *" s ", int " c );
18 .BI "char *strrchr(const char *" s ", int " c );
19 .fi
20 .SH DESCRIPTION
21 .TP
22 .BR strchr ()
23 The
24 .BR strchr ()
25 function returns a pointer to the first occurrence
26 of the character
27 .I c
28 in the string
29 .IR s .
30 .IP
31 It is equivalent to both of the following expressions:
32 .IP
33 .in +4n
34 .EX
35 memchr(s, c, strlen(s) + 1)
36 strpbrk(s, (char [2]){c, \[aq]\[rs]0\[aq]})
37 .EE
38 .in
39 .TP
40 .BR strrchr ()
41 The
42 .BR strrchr ()
43 function returns a pointer to the last occurrence
44 of the character
45 .I c
46 in the string
47 .IR s .
48 .IP
49 It is equivalent to
50 .IP
51 .in +4n
52 .EX
53 memrchr(s, c, strlen(s) + 1)
54 .EE
55 .in
56 .SH RETURN VALUE
57 The
58 .BR strchr ()
59 and
60 .BR strrchr ()
61 functions return a pointer to
62 the matched character or NULL if the character is not found.
63 The terminating null byte is considered part of the string,
64 so that if
65 .I c
66 is specified as \[aq]\[rs]0\[aq],
67 these functions return a pointer to the terminator.
68 .SH ATTRIBUTES
69 For an explanation of the terms used in this section, see
70 .BR attributes (7).
71 .TS
72 allbox;
73 lbx lb lb
74 l l l.
75 Interface Attribute Value
76 T{
77 .na
78 .nh
79 .BR strchr (),
80 .BR strrchr ()
81 T} Thread safety MT-Safe
82 .TE
83 .SH STANDARDS
84 C11, POSIX.1-2008.
85 .SH HISTORY
86 POSIX.1-2001, C89, SVr4, 4.3BSD.
87 .SH SEE ALSO
88 .BR memchr (3),
89 .BR string (3),
90 .BR strchrnul (3),
91 .BR strlen (3),
92 .BR strnul (3),
93 .BR strpbrk (3),
94 .BR strsep (3),
95 .BR strspn (3),
96 .BR strstr (3),
97 .BR strtok (3),
98 .BR wcschr (3),
99 .BR wcsrchr (3)