]>
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:54:34 1993, David Metcalfe | |
10 | .\" Modified Sat Jul 24 19:13:52 1993, Rik Faith (faith@cs.unc.edu) | |
ab47278f | 11 | .TH INDEX 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
12 | .SH NAME |
13 | index, rindex \- locate character in string | |
4508f8a0 AC |
14 | .SH LIBRARY |
15 | Standard C library | |
8fc3b2cf | 16 | .RI ( libc ", " \-lc ) |
fea681da MK |
17 | .SH SYNOPSIS |
18 | .nf | |
19 | .B #include <strings.h> | |
68e4db0a | 20 | .PP |
fea681da | 21 | .BI "char *index(const char *" s ", int " c ); |
fea681da MK |
22 | .BI "char *rindex(const char *" s ", int " c ); |
23 | .fi | |
24 | .SH DESCRIPTION | |
60a90ecd MK |
25 | The |
26 | .BR index () | |
27 | function returns a pointer to the first occurrence | |
fea681da MK |
28 | of the character \fIc\fP in the string \fIs\fP. |
29 | .PP | |
60a90ecd MK |
30 | The |
31 | .BR rindex () | |
32 | function returns a pointer to the last occurrence | |
fea681da MK |
33 | of the character \fIc\fP in the string \fIs\fP. |
34 | .PP | |
d1a71985 | 35 | The terminating null byte (\(aq\e0\(aq) is considered to be a part of the |
fea681da | 36 | strings. |
47297adb | 37 | .SH RETURN VALUE |
60a90ecd MK |
38 | The |
39 | .BR index () | |
40 | and | |
41 | .BR rindex () | |
42 | functions return a pointer to | |
fea681da | 43 | the matched character or NULL if the character is not found. |
8cad35ef | 44 | .SH ATTRIBUTES |
52274086 MK |
45 | For an explanation of the terms used in this section, see |
46 | .BR attributes (7). | |
c466875e MK |
47 | .ad l |
48 | .nh | |
52274086 MK |
49 | .TS |
50 | allbox; | |
c466875e | 51 | lbx lb lb |
52274086 MK |
52 | l l l. |
53 | Interface Attribute Value | |
54 | T{ | |
55 | .BR index (), | |
8cad35ef | 56 | .BR rindex () |
52274086 MK |
57 | T} Thread safety MT-Safe |
58 | .TE | |
c466875e MK |
59 | .hy |
60 | .ad | |
61 | .sp 1 | |
3113c7f3 | 62 | .SH STANDARDS |
68e1685c | 63 | 4.3BSD; marked as LEGACY in POSIX.1-2001. |
64e082ef | 64 | POSIX.1-2008 removes the specifications of |
97c8e181 MK |
65 | .BR index () |
66 | and | |
cbf4eee7 MK |
67 | .BR rindex (), |
68 | recommending | |
69 | .BR strchr (3) | |
70 | and | |
71 | .BR strrchr (3) | |
72 | instead. | |
47297adb | 73 | .SH SEE ALSO |
fea681da MK |
74 | .BR memchr (3), |
75 | .BR strchr (3), | |
d095200e | 76 | .BR string (3), |
fea681da MK |
77 | .BR strpbrk (3), |
78 | .BR strrchr (3), | |
79 | .BR strsep (3), | |
80 | .BR strspn (3), | |
81 | .BR strstr (3), | |
82 | .BR strtok (3) |