OSDN Git Service

(split) LDP: Update original to LDP v3.40.
[linuxjm/LDP_man-pages.git] / original / man3 / strchr.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Mon Apr 12 12:51:24 1993, David Metcalfe
28 .\" 2006-05-19, Justin Pryzby <pryzbyj@justinpryzby.com>
29 .\"     Document strchrnul(3).
30 .\"
31 .TH STRCHR 3  2012-04-24 "GNU" "Linux Programmer's Manual"
32 .SH NAME
33 strchr, strrchr, strchrnul \- locate character in string
34 .SH SYNOPSIS
35 .nf
36 .B #include <string.h>
37 .sp
38 .BI "char *strchr(const char *" s ", int " c );
39 .sp
40 .BI "char *strrchr(const char *" s ", int " c );
41 .sp
42 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
43 .B #include <string.h>
44 .sp
45 .BI "char *strchrnul(const char *" s ", int " c );
46 .fi
47 .SH DESCRIPTION
48 The
49 .BR strchr ()
50 function returns a pointer to the first occurrence
51 of the character
52 .I c
53 in the string
54 .IR s .
55 .PP
56 The
57 .BR strrchr ()
58 function returns a pointer to the last occurrence
59 of the character
60 .I c
61 in the string
62 .IR s .
63 .PP
64 The
65 .BR strchrnul ()
66 function is like
67 .BR strchr ()
68 except that if
69 .I c
70 is not found in
71 .IR s ,
72 then it returns a pointer to the null byte
73 at the end of
74 .IR s ,
75 rather than NULL.
76 .PP
77 Here "character" means "byte"; these functions do not work with
78 wide or multibyte characters.
79 .SH "RETURN VALUE"
80 The
81 .BR strchr ()
82 and
83 .BR strrchr ()
84 functions return a pointer to
85 the matched character or NULL if the character is not found.
86 The terminating null byte is considered part of the string,
87 so that if
88 .I c
89 is specified as \(aq\\0\(aq,
90 these functions return a pointer to the terminator.
91
92 The
93 .BR strchrnul ()
94 function returns a pointer to
95 the matched character,
96 or a pointer to the null
97 byte at the end of \fIs\fP (i.e., \fIs+strlen(s)\fP)
98 if the character is not found.
99 .SH VERSIONS
100 .BR strchrnul ()
101 first appeared in glibc in version 2.1.1.
102 .SH "CONFORMING TO"
103 .BR strchr ()
104 and
105 .BR strrchr ()
106 are in SVr4, 4.3BSD, C89, C99.
107 .BR strchrnul ()
108 is a GNU extension.
109 .SH "SEE ALSO"
110 .BR index (3),
111 .BR memchr (3),
112 .BR rindex (3),
113 .BR string (3),
114 .BR strlen (3),
115 .BR strpbrk (3),
116 .BR strsep (3),
117 .BR strspn (3),
118 .BR strstr (3),
119 .BR strtok (3),
120 .BR wcschr (3),
121 .BR wcsrchr (3)