1INDEX(3) Linux Programmer's Manual INDEX(3)
2
3
4
6 index, rindex - locate character in string
7
9 #include <strings.h>
10
11 char *index(const char *s, int c);
12 char *rindex(const char *s, int c);
13
15 The index() function returns a pointer to the first occurrence of the
16 character c in the string s.
17
18 The rindex() function returns a pointer to the last occurrence of the
19 character c in the string s.
20
21 The terminating null byte ('\0') is considered to be a part of the
22 strings.
23
25 The index() and rindex() functions return a pointer to the matched
26 character or NULL if the character is not found.
27
29 For an explanation of the terms used in this section, see at‐
30 tributes(7).
31
32 ┌────────────────────────────────────────────┬───────────────┬─────────┐
33 │Interface │ Attribute │ Value │
34 ├────────────────────────────────────────────┼───────────────┼─────────┤
35 │index(), rindex() │ Thread safety │ MT-Safe │
36 └────────────────────────────────────────────┴───────────────┴─────────┘
37
39 4.3BSD; marked as LEGACY in POSIX.1-2001. POSIX.1-2008 removes the
40 specifications of index() and rindex(), recommending strchr(3) and str‐
41 rchr(3) instead.
42
44 memchr(3), strchr(3), string(3), strpbrk(3), strrchr(3), strsep(3),
45 strspn(3), strstr(3), strtok(3)
46
48 This page is part of release 5.13 of the Linux man-pages project. A
49 description of the project, information about reporting bugs, and the
50 latest version of this page, can be found at
51 https://www.kernel.org/doc/man-pages/.
52
53
54
55GNU 2021-03-22 INDEX(3)