Debian Codegraph @

upstream/debian-unstable/man3/memchr.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH memchr 3 2026-02-25 "Linux man-pages 6.18"
8 .SH NAME
9 memchr, memrchr \- scan memory for a character
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <string.h>
16 .P
17 .BR "void *memchr(" "size_t n;"
18 .BI " const void " s [ n "], int " c ", size_t " n );
19 .BR "void *memrchr(" "size_t n;"
20 .BI " const void " s [ n "], int " c ", size_t " n );
21 .fi
22 .P
23 .RS -4
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
26 .RE
27 .P
28 .BR memrchr ():
29 .nf
30 _GNU_SOURCE
31 .fi
32 .SH DESCRIPTION
33 The
34 .BR memchr ()
35 function scans the initial
36 .I n
37 bytes of the memory
38 area pointed to by
39 .I s
40 for the first instance of
41 .IR c .
42 Both
43 .I c
44 and the bytes of the memory area pointed to by
45 .I s
46 are interpreted as
47 .IR "unsigned char" .
48 .P
49 The
50 .BR memrchr ()
51 function is like the
52 .BR memchr ()
53 function,
54 except that it searches backward from the end of the
55 .I n
56 bytes pointed to by
57 .I s
58 instead of forward from the beginning.
59 .SH RETURN VALUE
60 The
61 .BR memchr ()
62 and
63 .BR memrchr ()
64 functions return a pointer
65 to the matching byte or NULL if the character does not occur in
66 the given memory area.
67 .SH ATTRIBUTES
68 For an explanation of the terms used in this section, see
69 .BR attributes (7).
70 .TS
71 allbox;
72 lbx lb lb
73 l l l.
74 Interface Attribute Value
75 T{
76 .na
77 .nh
78 .BR memchr (),
79 .BR memrchr ()
80 T} Thread safety MT-Safe
81 .TE
82 .SH STANDARDS
83 .TP
84 .BR memchr ()
85 C11, POSIX.1-2008.
86 .TP
87 .BR memrchr ()
88 GNU.
89 .SH HISTORY
90 .TP
91 .BR memchr ()
92 POSIX.1-2001, C89, SVr4, 4.3BSD.
93 .TP
94 .BR memrchr ()
95 glibc 2.2.
96 .SH SEE ALSO
97 .BR bstring (3),
98 .BR ffs (3),
99 .BR memmem (3),
100 .BR strchr (3),
101 .BR strpbrk (3),
102 .BR strrchr (3),
103 .BR strsep (3),
104 .BR strspn (3),
105 .BR strstr (3),
106 .BR wmemchr (3)