Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ index(3C) — SunOS 5.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

string(3C)

bstring(3C)

malloc(3C)

index(3C)

NAME

index, rindex − string operations

SYNOPSIS

#include <strings.h>

char ∗index(const char ∗s, int c);

char ∗rindex(const char ∗s, int c);

DESCRIPTION

These functions operate on null-terminated strings. 

index() returns a pointer to the first occurrence of character c in string s, and rindex() returns a pointer to the last occurrence of character c in string s. Both index() and rindex() return a null pointer if c does not occur in the string.  The null character terminating a string is considered to be part of the string. 

SEE ALSO

string(3C), bstring(3C), malloc(3C)

NOTES

On most modern computer systems, you can not use a null pointer to indicate a null string.  A null pointer is an error and results in an abort of the program.  If you wish to indicate a null string, you must have a pointer that points to an explicit null string.  On some implementations of the C language on some machines, a null pointer, if dereferenced, would yield a null string; this highly non-portable trick was used in some programs.  Programmers using a null pointer to represent an empty string should be aware of this portability issue; even on machines where dereferencing a null pointer does not cause an abort of the program, it does not necessarily yield a null string. 

SunOS 5.5  —  Last change: 3 March 1995

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026