1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe
8 .\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu)
9 .\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com)
10 .\" 2008-07-09, mtk, add rawmemchr()
12 .TH memchr 3 (date) "Linux man-pages (unreleased)"
14 memchr, memrchr, rawmemchr \- scan memory for a character
17 .RI ( libc ", " \-lc )
20 .B #include <string.h>
22 .BI "void *memchr(const void *" s ", int " c ", size_t " n );
23 .BI "void *memrchr(const void *" s ", int " c ", size_t " n );
24 .BI "void *rawmemchr(const void *" s ", int " c );
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
40 function scans the initial
45 for the first instance of
49 and the bytes of the memory area pointed to by
59 except that it searches backward from the end of the
63 instead of forward from the beginning.
67 function is similar to
69 it assumes (i.e., the programmer knows for certain)
72 lies somewhere in the memory area starting at the location pointed to by
74 and so performs an optimized search for
76 (i.e., no use of a count argument to limit the range of the search).
79 is not found, the results are unpredictable.
80 The following call is a fast means of locating a string's
81 terminating null byte:
85 char *p = rawmemchr(s,\ \(aq\e0\(aq);
93 functions return a pointer
94 to the matching byte or NULL if the character does not occur in
95 the given memory area.
99 function returns a pointer to the matching byte, if one is found.
100 If no matching byte is found, the result is unspecified.
103 first appeared in glibc in version 2.1.
106 first appeared in glibc in version 2.2.
108 For an explanation of the terms used in this section, see
116 Interface Attribute Value
121 T} Thread safety MT-Safe
128 POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.
132 function is a GNU extension, available since glibc 2.1.91.
136 function is a GNU extension, available since glibc 2.1.