]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strchr.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / strchr.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
4.\"
5.\" References consulted:
6.\" Linux libc source code
7.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8.\" 386BSD man pages
9.\" Modified Mon Apr 12 12:51:24 1993, David Metcalfe
a0bf3577
MK
10.\" 2006-05-19, Justin Pryzby <pryzbyj@justinpryzby.com>
11.\" Document strchrnul(3).
c13182ef 12.\"
45186a5d 13.TH STRCHR 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da 14.SH NAME
e9d27e13 15strchr, strrchr, strchrnul \- locate character in string
52533a8b
AC
16.SH LIBRARY
17Standard C library
8fc3b2cf 18.RI ( libc ", " \-lc )
fea681da
MK
19.SH SYNOPSIS
20.nf
21.B #include <string.h>
68e4db0a 22.PP
fea681da 23.BI "char *strchr(const char *" s ", int " c );
fea681da 24.BI "char *strrchr(const char *" s ", int " c );
eaa18d3c 25.PP
b80f966b 26.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
e9d27e13 27.B #include <string.h>
68e4db0a 28.PP
7145b9a9 29.BI "char *strchrnul(const char *" s ", int " c );
fea681da
MK
30.fi
31.SH DESCRIPTION
60a90ecd
MK
32The
33.BR strchr ()
34function returns a pointer to the first occurrence
dc6a909b
MK
35of the character
36.I c
37in the string
38.IR s .
fea681da 39.PP
60a90ecd
MK
40The
41.BR strrchr ()
42function returns a pointer to the last occurrence
dc6a909b
MK
43of the character
44.I c
45in the string
46.IR s .
fea681da 47.PP
60a90ecd
MK
48The
49.BR strchrnul ()
50function is like
51.BR strchr ()
dc6a909b
MK
52except that if
53.I c
54is not found in
55.IR s ,
c13182ef 56then it returns a pointer to the null byte
dc6a909b
MK
57at the end of
58.IR s ,
59rather than NULL.
e9d27e13 60.PP
c65433e6 61Here "character" means "byte"; these functions do not work with
ae03dc66 62wide or multibyte characters.
47297adb 63.SH RETURN VALUE
60a90ecd
MK
64The
65.BR strchr ()
66and
67.BR strrchr ()
68functions return a pointer to
fea681da 69the matched character or NULL if the character is not found.
2c4d293c
JH
70The terminating null byte is considered part of the string,
71so that if
72.I c
d1a71985 73is specified as \(aq\e0\(aq,
2c4d293c 74these functions return a pointer to the terminator.
847e0d88 75.PP
60a90ecd
MK
76The
77.BR strchrnul ()
6c22b2c5
MK
78function returns a pointer to the matched character,
79or a pointer to the null byte at the end of
46d8df8e 80.I s
51700fd7 81(i.e.,
46d8df8e 82.IR "s+strlen(s)" )
e9d27e13 83if the character is not found.
266b5355
MK
84.SH VERSIONS
85.BR strchrnul ()
86first appeared in glibc in version 2.1.1.
5745405b 87.SH ATTRIBUTES
00713037
PH
88For an explanation of the terms used in this section, see
89.BR attributes (7).
c466875e
MK
90.ad l
91.nh
00713037
PH
92.TS
93allbox;
c466875e 94lbx lb lb
00713037
PH
95l l l.
96Interface Attribute Value
97T{
5745405b
PH
98.BR strchr (),
99.BR strrchr (),
5745405b 100.BR strchrnul ()
00713037
PH
101T} Thread safety MT-Safe
102.TE
c466875e
MK
103.hy
104.ad
105.sp 1
3113c7f3 106.SH STANDARDS
3767e433
MK
107.BR strchr (),
108.BR strrchr ():
109POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.
847e0d88 110.PP
60a90ecd
MK
111.BR strchrnul ()
112is a GNU extension.
47297adb 113.SH SEE ALSO
fea681da
MK
114.BR index (3),
115.BR memchr (3),
116.BR rindex (3),
d095200e 117.BR string (3),
e9d27e13 118.BR strlen (3),
fea681da
MK
119.BR strpbrk (3),
120.BR strsep (3),
121.BR strspn (3),
122.BR strstr (3),
123.BR strtok (3),
124.BR wcschr (3),
0a4f8b7b 125.BR wcsrchr (3)