]>
Commit | Line | Data |
---|---|---|
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 | 15 | strchr, strrchr, strchrnul \- locate character in string |
52533a8b AC |
16 | .SH LIBRARY |
17 | Standard 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 |
32 | The |
33 | .BR strchr () | |
34 | function returns a pointer to the first occurrence | |
dc6a909b MK |
35 | of the character |
36 | .I c | |
37 | in the string | |
38 | .IR s . | |
fea681da | 39 | .PP |
60a90ecd MK |
40 | The |
41 | .BR strrchr () | |
42 | function returns a pointer to the last occurrence | |
dc6a909b MK |
43 | of the character |
44 | .I c | |
45 | in the string | |
46 | .IR s . | |
fea681da | 47 | .PP |
60a90ecd MK |
48 | The |
49 | .BR strchrnul () | |
50 | function is like | |
51 | .BR strchr () | |
dc6a909b MK |
52 | except that if |
53 | .I c | |
54 | is not found in | |
55 | .IR s , | |
c13182ef | 56 | then it returns a pointer to the null byte |
dc6a909b MK |
57 | at the end of |
58 | .IR s , | |
59 | rather than NULL. | |
e9d27e13 | 60 | .PP |
c65433e6 | 61 | Here "character" means "byte"; these functions do not work with |
ae03dc66 | 62 | wide or multibyte characters. |
47297adb | 63 | .SH RETURN VALUE |
60a90ecd MK |
64 | The |
65 | .BR strchr () | |
66 | and | |
67 | .BR strrchr () | |
68 | functions return a pointer to | |
fea681da | 69 | the matched character or NULL if the character is not found. |
2c4d293c JH |
70 | The terminating null byte is considered part of the string, |
71 | so that if | |
72 | .I c | |
d1a71985 | 73 | is specified as \(aq\e0\(aq, |
2c4d293c | 74 | these functions return a pointer to the terminator. |
847e0d88 | 75 | .PP |
60a90ecd MK |
76 | The |
77 | .BR strchrnul () | |
6c22b2c5 MK |
78 | function returns a pointer to the matched character, |
79 | or 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 | 83 | if the character is not found. |
266b5355 MK |
84 | .SH VERSIONS |
85 | .BR strchrnul () | |
86 | first appeared in glibc in version 2.1.1. | |
5745405b | 87 | .SH ATTRIBUTES |
00713037 PH |
88 | For 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 |
93 | allbox; | |
c466875e | 94 | lbx lb lb |
00713037 PH |
95 | l l l. |
96 | Interface Attribute Value | |
97 | T{ | |
5745405b PH |
98 | .BR strchr (), |
99 | .BR strrchr (), | |
5745405b | 100 | .BR strchrnul () |
00713037 PH |
101 | T} 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 (): | |
109 | POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD. | |
847e0d88 | 110 | .PP |
60a90ecd MK |
111 | .BR strchrnul () |
112 | is 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) |