.TH index() "" "" "String Function (libc)"
.PC "Find a character in a string"
.B "#include <string.h>"
\fBchar *index(\fIstring\^\fB, \fIc\^\fB) char *\fIstring\^\fB; char \fIc\^\fB;\fR
.PP
.B index()
scans the given
.I string
for the first occurrence of the character
.IR c .
If
.I c
is found,
.B index()
returns a pointer to it.
If it is not found,
.B index()
returns NULL.
.PP
Note that having \fBindex()\fR search for a
NUL character will always produce a pointer to the end of a string.
For example,
.DM
	char *string;
	assert(index(string, 0)==string+strlen(string));
.DE
.PP
will never fail.
.SH Example
For an example of this function, see the entry for
.BR strncpy() .
.SH "See Also"
.Xr "libc," libc
.Xr "pnmatch()," pnmatch
.Xr "strchr()," strchr
.Xr "string.h," string.h
.Xr "strrchr()," strrchr
.Xr "string.h" string.h
.SH Notes
You
.I must
include header file
.B string.h
in any program that uses
.BR index() ,
or that program will not link correctly.
.PP
.B index()
is now obsolete.
You should use
.B strchr()
instead.
