1index(3C)                Standard C Library Functions                index(3C)
2
3
4

NAME

6       index, rindex - string operations
7

SYNOPSIS

9       #include <strings.h>
10
11       char *index(const char *s, int c);
12
13
14       char *rindex(const char *s, int c);
15
16

DESCRIPTION

18       The index() and rindex() functions operate on null-terminated strings.
19
20
21       The index() function returns a pointer to the first occurrence of char‐
22       acter c in string s.
23
24
25       The rindex() function returns a pointer to the last occurrence of char‐
26       acter c in string s.
27
28
29       Both index() and  rindex() return a null pointer if c does not occur in
30       the string. The null character terminating a string is considered to be
31       part of the string.
32

USAGE

34       On  most  modern  computer  systems,  you can not use a null pointer to
35       indicate a null string.  A null pointer is an error and results  in  an
36       abort  of the program.  If you wish to indicate a null string, you must
37       use a pointer that points to an explicit null string.  On some machines
38       and  with  some  implementations  of the C programming language, a null
39       pointer, if dereferenced, would yield  a  null  string.   Though  often
40       used,  this  practice  is not always portable. Programmers using a null
41       pointer to represent an empty string should be aware of this  portabil‐
42       ity  issue.   Even  on machines where dereferencing a null pointer does
43       not cause an abort of the program, it does not necessarily yield a null
44       string.
45

ATTRIBUTES

47       See attributes(5) for descriptions of the following attributes:
48
49
50
51
52       ┌─────────────────────────────┬─────────────────────────────┐
53ATTRIBUTE TYPE               ATTRIBUTE VALUE              
54       ├─────────────────────────────┼─────────────────────────────┤
55       │Interface Stability          │Standard                     │
56       └─────────────────────────────┴─────────────────────────────┘
57

SEE ALSO

59       bstring(3C), malloc(3C), string(3C), attributes(5), standards(5)
60
61
62
63SunOS 5.11                        24 Jul 2002                        index(3C)
Impressum