1STRCHR(3)                  Linux Programmer's Manual                 STRCHR(3)
2
3
4

NAME

6       strchr, strrchr, strchrnul - locate character in string
7

SYNOPSIS

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         /* See feature_test_macros(7) */
16       #include <string.h>
17
18       char *strchrnul(const char *s, int c);
19

DESCRIPTION

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

RETURN VALUE

35       The strchr() and strrchr() functions return a pointer  to  the  matched
36       character  or NULL if the character is not found.  The terminating null
37       byte is considered part of the string, so that if  c  is  specified  as
38       '\0', these functions return a pointer to the terminator.
39
40       The strchrnul() function returns a pointer to the matched character, or
41       a pointer to the null byte at the end of s (i.e., s+strlen(s))  if  the
42       character is not found.
43

VERSIONS

45       strchrnul() first appeared in glibc in version 2.1.1.
46

ATTRIBUTES

48       For   an   explanation   of   the  terms  used  in  this  section,  see
49       attributes(7).
50
51       ┌─────────────────────────────────┬───────────────┬─────────┐
52Interface                        Attribute     Value   
53       ├─────────────────────────────────┼───────────────┼─────────┤
54strchr(), strrchr(), strchrnul() │ Thread safety │ MT-Safe │
55       └─────────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

57       strchr(),  strrchr():  POSIX.1-2001,  POSIX.1-2008,  C89,  C99,   SVr4,
58       4.3BSD.
59
60       strchrnul() is a GNU extension.
61

SEE ALSO

63       index(3),   memchr(3),  rindex(3),  string(3),  strlen(3),  strpbrk(3),
64       strsep(3), strspn(3), strstr(3), strtok(3), wcschr(3), wcsrchr(3)
65

COLOPHON

67       This page is part of release 5.04 of the Linux  man-pages  project.   A
68       description  of  the project, information about reporting bugs, and the
69       latest    version    of    this    page,    can     be     found     at
70       https://www.kernel.org/doc/man-pages/.
71
72
73
74GNU                               2019-03-06                         STRCHR(3)
Impressum