1strchr(3)                  Library Functions Manual                  strchr(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <string.h>
13
14       char *strchr(const char *s, int c);
15       char *strrchr(const char *s, int c);
16
17       #define _GNU_SOURCE         /* See feature_test_macros(7) */
18       #include <string.h>
19
20       char *strchrnul(const char *s, int c);
21

DESCRIPTION

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

RETURN VALUE

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

STANDARDS

57       strchr()
58       strrchr()
59              C11, POSIX.1-2008.
60
61       strchrnul()
62              GNU.
63

HISTORY

65       strchr()
66       strrchr()
67              POSIX.1-2001, C89, SVr4, 4.3BSD.
68
69       strchrnul()
70              glibc 2.1.1.
71

SEE ALSO

73       memchr(3),  string(3),  strlen(3),  strpbrk(3),  strsep(3),  strspn(3),
74       strstr(3), strtok(3), wcschr(3), wcsrchr(3)
75
76
77
78Linux man-pages 6.04              2023-03-30                         strchr(3)
Impressum