COHERENT manpages

This page displays the COHERENT manpage for index() [Find a character in a string].

List of available manpages
Index


index() -- String Function (libc)

Find a character in a string
#include <string.h>
char *index(string, c) char *string; char c;

index() scans the given string for the first occurrence of the character c.
If  c is  found, index()  returns a  pointer to  it.  If  it is  not found,
index() returns NULL.

Note that having  index() search for a NUL character  will always produce a
pointer to the end of a string.  For example,

    char *string;
    assert(index(string, 0)==string+strlen(string));

will never fail.

Example

For an example of this function, see the entry for strncpy().

See Also

libc,
pnmatch(),
strchr(),
string.h,
strrchr(),
string.h

Notes

You must include header file string.h  in any program that uses index(), or
that program will not link correctly.

index() is now obsolete.  You should use strchr() instead.