1STRRCHR(3P) POSIX Programmer's Manual STRRCHR(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 strrchr - string scanning operation
13
15 #include <string.h>
16
17 char *strrchr(const char *s, int c);
18
19
21 The strrchr() function shall locate the last occurrence of c (converted
22 to a char) in the string pointed to by s. The terminating null byte is
23 considered to be part of the string.
24
26 Upon successful completion, strrchr() shall return a pointer to the
27 byte or a null pointer if c does not occur in the string.
28
30 No errors are defined.
31
32 The following sections are informative.
33
35 Finding the Base Name of a File
36 The following example uses strrchr() to get a pointer to the base name
37 of a file. The strrchr() function searches backwards through the name
38 of the file to find the last '/' character in name. This pointer (plus
39 one) will point to the base name of the file.
40
41
42 #include <string.h>
43 ...
44 const char *name;
45 char *basename;
46 ...
47 basename = strrchr(name, '/') + 1;
48 ...
49
51 None.
52
54 None.
55
57 None.
58
60 strchr(), the Base Definitions volume of IEEE Std 1003.1-2001,
61 <string.h>
62
64 Portions of this text are reprinted and reproduced in electronic form
65 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
66 -- Portable Operating System Interface (POSIX), The Open Group Base
67 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
68 Electrical and Electronics Engineers, Inc and The Open Group. In the
69 event of any discrepancy between this version and the original IEEE and
70 The Open Group Standard, the original IEEE and The Open Group Standard
71 is the referee document. The original Standard can be obtained online
72 at http://www.opengroup.org/unix/online.html .
73
74
75
76IEEE/The Open Group 2003 STRRCHR(3P)