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

DESCRIPTION

20       The  strchr() function returns a pointer to the first occurrence of the
21       character c in the string s.
22
23       The strrchr() function returns a pointer to the last occurrence of  the
24       character c in the string s.
25
26       The strchrnul() function is like strchr() except that if c is not found
27       in s, then it returns a pointer to the null  byte  at  the  end  of  s,
28       rather than NULL.
29
30       Here "character" means "byte"; these functions do not work with wide or
31       multibyte characters.
32

RETURN VALUE

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

VERSIONS

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

ATTRIBUTES

47       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
48       tributes(7).
49
50       ┌────────────────────────────────────────────┬───────────────┬─────────┐
51Interface                                   Attribute     Value   
52       ├────────────────────────────────────────────┼───────────────┼─────────┤
53strchr(), strrchr(), strchrnul()            │ Thread safety │ MT-Safe │
54       └────────────────────────────────────────────┴───────────────┴─────────┘
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.13 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                               2021-03-22                         STRCHR(3)
Impressum