malloc_get_state.3: tfix
[man-pages.git] / man3 / strchr.3
bloba0b925e9669c5335ae73854239d5601d01b1d67b
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\"     Linux libc source code
8 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\"     386BSD man pages
10 .\" Modified Mon Apr 12 12:51:24 1993, David Metcalfe
11 .\" 2006-05-19, Justin Pryzby <pryzbyj@justinpryzby.com>
12 .\"     Document strchrnul(3).
13 .\"
14 .TH strchr 3 (date) "Linux man-pages (unreleased)"
15 .SH NAME
16 strchr, strrchr, strchrnul \- locate character in string
17 .SH LIBRARY
18 Standard C library
19 .RI ( libc ", " \-lc )
20 .SH SYNOPSIS
21 .nf
22 .B #include <string.h>
24 .BI "char *strchr(const char *" s ", int " c );
25 .BI "char *strrchr(const char *" s ", int " c );
27 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
28 .B #include <string.h>
30 .BI "char *strchrnul(const char *" s ", int " c );
31 .fi
32 .SH DESCRIPTION
33 The
34 .BR strchr ()
35 function returns a pointer to the first occurrence
36 of the character
37 .I c
38 in the string
39 .IR s .
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 .
49 The
50 .BR strchrnul ()
51 function is like
52 .BR strchr ()
53 except that if
54 .I c
55 is not found in
56 .IR s ,
57 then it returns a pointer to the null byte
58 at the end of
59 .IR s ,
60 rather than NULL.
62 Here "character" means "byte"; these functions do not work with
63 wide or multibyte characters.
64 .SH RETURN VALUE
65 The
66 .BR strchr ()
67 and
68 .BR strrchr ()
69 functions return a pointer to
70 the matched character or NULL if the character is not found.
71 The terminating null byte is considered part of the string,
72 so that if
73 .I c
74 is specified as \[aq]\e0\[aq],
75 these functions return a pointer to the terminator.
77 The
78 .BR strchrnul ()
79 function returns a pointer to the matched character,
80 or a pointer to the null byte at the end of
81 .I s
82 (i.e.,
83 .IR "s+strlen(s)" )
84 if the character is not found.
85 .SH ATTRIBUTES
86 For an explanation of the terms used in this section, see
87 .BR attributes (7).
88 .TS
89 allbox;
90 lbx lb lb
91 l l l.
92 Interface       Attribute       Value
94 .na
95 .nh
96 .BR strchr (),
97 .BR strrchr (),
98 .BR strchrnul ()
99 T}      Thread safety   MT-Safe
101 .SH STANDARDS
103 .BR strchr ()
105 .BR strrchr ()
106 C11, POSIX.1-2008.
108 .BR strchrnul ()
109 GNU.
110 .SH HISTORY
112 .BR strchr ()
114 .BR strrchr ()
115 POSIX.1-2001, C89, SVr4, 4.3BSD.
117 .BR strchrnul ()
118 glibc 2.1.1.
119 .SH SEE ALSO
120 .BR memchr (3),
121 .BR string (3),
122 .BR strlen (3),
123 .BR strpbrk (3),
124 .BR strsep (3),
125 .BR strspn (3),
126 .BR strstr (3),
127 .BR strtok (3),
128 .BR wcschr (3),
129 .BR wcsrchr (3)