1STRCHR(3) Linux Programmer's Manual STRCHR(3)
2
3
4
6 strchr, strrchr, strchrnul - locate character in string
7
9 #include <string.h>
10
11 char *strchr(const char *s, int c);
12
13 char *strrchr(const char *s, int c);
14
15 #define _GNU_SOURCE
16 #include <string.h>
17
18 char *strchrnul(const char *s, int c);
19
21 The strchr() function returns a pointer to the first occurrence of the
22 character c in the string s.
23
24 The strrchr() function returns a pointer to the last occurrence of the
25 character c in the string s.
26
27 The strchrnul() function is like strchr() except that if c is not found
28 in s, then it returns a pointer to the null byte at the end of s,
29 rather than NULL.
30
31 Here "character" means "byte"; these functions do not work with wide or
32 multibyte characters.
33
35 The strchr() and strrchr() functions return a pointer to the matched
36 character or NULL if the character is not found.
37
38 The strchrnul() function returns a pointer to the matched character, or
39 a pointer to the null byte at the end of s (i.e., s+strlen(s)) if the
40 character is not found.
41
43 strchrnul() first appeared in glibc in version 2.1.1.
44
46 strchr() and strrchr() are in SVr4, 4.3BSD, C89, C99. strchrnul() is a
47 GNU extension.
48
50 index(3), memchr(3), rindex(3), strlen(3), strpbrk(3), strsep(3), str‐
51 spn(3), strstr(3), strtok(3), wcschr(3), wcsrchr(3), fea‐
52 ture_test_macros(7)
53
55 This page is part of release 3.25 of the Linux man-pages project. A
56 description of the project, and information about reporting bugs, can
57 be found at http://www.kernel.org/doc/man-pages/.
58
59
60
61GNU 2008-08-11 STRCHR(3)