mirror of https://github.com/mkerrisk/man-pages
75 lines
2.0 KiB
Plaintext
75 lines
2.0 KiB
Plaintext
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
|
.TH "STRRCHR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
|
.\" strrchr
|
|
.SH NAME
|
|
strrchr \- string scanning operation
|
|
.SH SYNOPSIS
|
|
.LP
|
|
\fB#include <string.h>
|
|
.br
|
|
.sp
|
|
char *strrchr(const char *\fP\fIs\fP\fB, int\fP \fIc\fP\fB);
|
|
.br
|
|
\fP
|
|
.SH DESCRIPTION
|
|
.LP
|
|
The \fIstrrchr\fP() function shall locate the last occurrence of \fIc\fP
|
|
(converted to a \fBchar\fP) in the string pointed to
|
|
by \fIs\fP. The terminating null byte is considered to be part of
|
|
the string.
|
|
.SH RETURN VALUE
|
|
.LP
|
|
Upon successful completion, \fIstrrchr\fP() shall return a pointer
|
|
to the byte or a null pointer if \fIc\fP does not occur in
|
|
the string.
|
|
.SH ERRORS
|
|
.LP
|
|
No errors are defined.
|
|
.LP
|
|
\fIThe following sections are informative.\fP
|
|
.SH EXAMPLES
|
|
.SS Finding the Base Name of a File
|
|
.LP
|
|
The following example uses \fIstrrchr\fP() to get a pointer to the
|
|
base name of a file. The \fIstrrchr\fP() function searches
|
|
backwards through the name of the file to find the last \fB'/'\fP
|
|
character in \fIname\fP. This pointer (plus one) will point
|
|
to the base name of the file.
|
|
.sp
|
|
.RS
|
|
.nf
|
|
|
|
\fB#include <string.h>
|
|
\&...
|
|
const char *name;
|
|
char *basename;
|
|
\&...
|
|
basename = strrchr(name, '/') + 1;
|
|
\&...
|
|
\fP
|
|
.fi
|
|
.RE
|
|
.SH APPLICATION USAGE
|
|
.LP
|
|
None.
|
|
.SH RATIONALE
|
|
.LP
|
|
None.
|
|
.SH FUTURE DIRECTIONS
|
|
.LP
|
|
None.
|
|
.SH SEE ALSO
|
|
.LP
|
|
\fIstrchr\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
|
\fI<string.h>\fP
|
|
.SH COPYRIGHT
|
|
Portions of this text are reprinted and reproduced in electronic form
|
|
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
|
-- Portable Operating System Interface (POSIX), The Open Group Base
|
|
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
|
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
|
event of any discrepancy between this version 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 .
|