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