Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ index(3B) — SunOS 5.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bstring(3B)

malloc(3C)

index(3B)

NAME

index, rindex − string operations

SYNOPSIS

/usr/ucb/cc [ flag ... ] file ...

#include <strings.h>

char ∗index( s, c)
register char ∗s;
register char c;

char ∗rindex( s, c)
register char ∗s;
register char 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

bstring(3B), malloc(3C)

NOTES

Use of these interfaces should be restricted to only applications written on BSD platforms.  Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. 

On the Sun processor, as well as on many other machines, 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.4  —  Last change: 11 Oct 1993

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