ioctl_tty.2: Update DTR example
[man-pages.git] / man3 / index.3
blob59acf7a1af2d087f5cb76cfd06820038887b4181
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 2021-03-22 "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 .PP
38 .BI "char *index(const char *" s ", int " c );
39 .BI "char *rindex(const char *" s ", int " c );
40 .fi
41 .SH DESCRIPTION
42 The
43 .BR index ()
44 function returns a pointer to the first occurrence
45 of the character \fIc\fP in the string \fIs\fP.
46 .PP
47 The
48 .BR rindex ()
49 function returns a pointer to the last occurrence
50 of the character \fIc\fP in the string \fIs\fP.
51 .PP
52 The terminating null byte (\(aq\e0\(aq) is considered to be a part of the
53 strings.
54 .SH RETURN VALUE
55 The
56 .BR index ()
57 and
58 .BR rindex ()
59 functions return a pointer to
60 the matched character or NULL if the character is not found.
61 .SH ATTRIBUTES
62 For an explanation of the terms used in this section, see
63 .BR attributes (7).
64 .ad l
65 .nh
66 .TS
67 allbox;
68 lbx lb lb
69 l l l.
70 Interface       Attribute       Value
72 .BR index (),
73 .BR rindex ()
74 T}      Thread safety   MT-Safe
75 .TE
76 .hy
77 .ad
78 .sp 1
79 .SH CONFORMING TO
80 4.3BSD; marked as LEGACY in POSIX.1-2001.
81 POSIX.1-2008 removes the specifications of
82 .BR index ()
83 and
84 .BR rindex (),
85 recommending
86 .BR strchr (3)
87 and
88 .BR strrchr (3)
89 instead.
90 .SH SEE ALSO
91 .BR memchr (3),
92 .BR strchr (3),
93 .BR string (3),
94 .BR strpbrk (3),
95 .BR strrchr (3),
96 .BR strsep (3),
97 .BR strspn (3),
98 .BR strstr (3),
99 .BR strtok (3)