OSDN Git Service

a913ef94afe32fadd7820fab6ba9d6ae13ae2355
[linuxjm/LDP_man-pages.git] / original / man3 / index.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Mon Apr 12 12:54:34 1993, David Metcalfe
30 .\" Modified Sat Jul 24 19:13:52 1993, Rik Faith (faith@cs.unc.edu)
31 .TH INDEX 3 2014-04-01 "GNU" "Linux Programmer's Manual"
32 .SH NAME
33 index, rindex \- locate character in string
34 .SH SYNOPSIS
35 .nf
36 .B #include <strings.h>
37 .sp
38 .BI "char *index(const char *" s ", int " c );
39 .sp
40 .BI "char *rindex(const char *" s ", int " c );
41 .fi
42 .SH DESCRIPTION
43 The
44 .BR index ()
45 function returns a pointer to the first occurrence
46 of the character \fIc\fP in the string \fIs\fP.
47 .PP
48 The
49 .BR rindex ()
50 function returns a pointer to the last occurrence
51 of the character \fIc\fP in the string \fIs\fP.
52 .PP
53 The terminating null byte (\(aq\\0\(aq) is considered to be a part of the
54 strings.
55 .SH RETURN VALUE
56 The
57 .BR index ()
58 and
59 .BR rindex ()
60 functions return a pointer to
61 the matched character or NULL if the character is not found.
62 .SH ATTRIBUTES
63 .SS Multithreading (see pthreads(7))
64 The
65 .BR index ()
66 and
67 .BR rindex ()
68 functions are thread-safe.
69 .SH CONFORMING TO
70 4.3BSD; marked as LEGACY in POSIX.1-2001.
71 POSIX.1-2008 removes the specifications of
72 .BR index ()
73 and
74 .BR rindex (),
75 recommending
76 .BR strchr (3)
77 and
78 .BR strrchr (3)
79 instead.
80 .SH SEE ALSO
81 .BR memchr (3),
82 .BR strchr (3),
83 .BR string (3),
84 .BR strpbrk (3),
85 .BR strrchr (3),
86 .BR strsep (3),
87 .BR strspn (3),
88 .BR strstr (3),
89 .BR strtok (3)
90 .SH COLOPHON
91 This page is part of release 3.67 of the Linux
92 .I man-pages
93 project.
94 A description of the project,
95 information about reporting bugs,
96 and the latest version of this page,
97 can be found at
98 \%http://www.kernel.org/doc/man\-pages/.