1 '\" te
   2 .\"  Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved  Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
   3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   4 .\" http://www.opengroup.org/bookstore/.
   5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   6 .\"  This notice shall appear on any product containing this material.
   7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  10 .TH INDEX 3C "Jul 24, 2002"
  11 .SH NAME
  12 index, rindex \- string operations
  13 .SH SYNOPSIS
  14 .LP
  15 .nf
  16 #include <strings.h>
  17 
  18 \fBchar *\fR\fBindex\fR(\fBconst char *\fR\fIs\fR, \fBint\fR \fIc\fR);
  19 .fi
  20 
  21 .LP
  22 .nf
  23 \fBchar *\fR\fBrindex\fR(\fBconst char *\fR\fIs\fR, \fBint\fR \fIc\fR);
  24 .fi
  25 
  26 .SH DESCRIPTION
  27 .sp
  28 .LP
  29 The \fBindex()\fR and \fBrindex()\fR functions operate on null-terminated
  30 strings.
  31 .sp
  32 .LP
  33 The \fBindex()\fR function returns a pointer to the first occurrence of
  34 character \fIc\fR in string \fIs\fR.
  35 .sp
  36 .LP
  37 The \fBrindex()\fR function returns a pointer to the last occurrence of
  38 character \fIc\fR in string \fIs\fR.
  39 .sp
  40 .LP
  41 Both \fBindex()\fR and  \fBrindex()\fR return a null pointer if \fIc\fR does
  42 not occur in the string. The null character terminating a string is considered
  43 to be part of the string.
  44 .SH USAGE
  45 .sp
  46 .LP
  47 On most modern computer systems, you can \fInot\fR use a null pointer to
  48 indicate a null string.  A null pointer is an error and results in an abort of
  49 the program.  If you wish to indicate a null string, you must use a pointer
  50 that points to an explicit null string.  On some machines and with some
  51 implementations of the C programming language, a null pointer, if dereferenced,
  52 would yield a null string.  Though often used, this practice is not always
  53 portable. Programmers using a null pointer to represent an empty string should
  54 be aware of this portability issue.  Even on machines where dereferencing a
  55 null pointer does not cause an abort of the program, it does not necessarily
  56 yield a null string.
  57 .SH ATTRIBUTES
  58 .sp
  59 .LP
  60 See \fBattributes\fR(5) for descriptions of the following attributes:
  61 .sp
  62 
  63 .sp
  64 .TS
  65 box;
  66 c | c
  67 l | l .
  68 ATTRIBUTE TYPE  ATTRIBUTE VALUE
  69 _
  70 Interface Stability     Standard
  71 .TE
  72 
  73 .SH SEE ALSO
  74 .sp
  75 .LP
  76 \fBbstring\fR(3C), \fBmalloc\fR(3C), \fBstring\fR(3C), \fBattributes\fR(5),
  77 \fBstandards\fR(5)