]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/memchr.3
memchr.3: rawmemchr doesn't have an n parameter
[thirdparty/man-pages.git] / man3 / memchr.3
CommitLineData
a1eaacb1 1'\" t
fea681da 2.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2a8bb904
MK
3.\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
4.\" <mtk.manpages@gmail.com>
fea681da 5.\"
5fbde956 6.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
7.\"
8.\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe
9.\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu)
10.\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com)
2a8bb904 11.\" 2008-07-09, mtk, add rawmemchr()
fea681da 12.\"
4c1c5274 13.TH memchr 3 (date) "Linux man-pages (unreleased)"
fea681da 14.SH NAME
2a8bb904 15memchr, memrchr, rawmemchr \- scan memory for a character
0a2adce0
AC
16.SH LIBRARY
17Standard C library
8fc3b2cf 18.RI ( libc ", " \-lc )
fea681da
MK
19.SH SYNOPSIS
20.nf
21.B #include <string.h>
dbfe9c70 22.PP
c64cd13e
AC
23.BI "void *memchr(const void " s [. n "], int " c ", size_t " n );
24.BI "void *memrchr(const void " s [. n "], int " c ", size_t " n );
b2af20ea 25.PP
afb2a42b 26.BI "[[deprecated]] void *rawmemchr(const void *" s ", int " c );
fea681da 27.fi
68e4db0a 28.PP
d39ad78f 29.RS -4
2a8bb904
MK
30Feature Test Macro Requirements for glibc (see
31.BR feature_test_macros (7)):
d39ad78f 32.RE
68e4db0a 33.PP
13a7959b 34.BR memrchr (),
2a8bb904 35.BR rawmemchr ():
1dd0d7b4
MK
36.nf
37 _GNU_SOURCE
38.fi
fea681da 39.SH DESCRIPTION
c13182ef 40The
63aa9df0 41.BR memchr ()
9640b1b3
MK
42function scans the initial
43.I n
44bytes of the memory
45area pointed to by
46.I s
47for the first instance of
48.IR c .
49Both
50.I c
51and the bytes of the memory area pointed to by
52.I s
53are interpreted as
54.IR "unsigned char" .
fea681da 55.PP
c13182ef 56The
63aa9df0 57.BR memrchr ()
c13182ef 58function is like the
63aa9df0 59.BR memchr ()
fea681da 60function,
9640b1b3
MK
61except that it searches backward from the end of the
62.I n
63bytes pointed to by
64.I s
65instead of forward from the beginning.
847e0d88 66.PP
2a8bb904
MK
67The
68.BR rawmemchr ()
69function is similar to
b2af20ea
AC
70.BR memchr (),
71but it assumes
72(i.e., the programmer knows for certain)
9640b1b3 73that an instance of
2a8bb904 74.I c
9640b1b3 75lies somewhere in the memory area starting at the location pointed to by
b2af20ea 76.IR s .
9640b1b3 77If an instance of
2a8bb904 78.I c
b2af20ea
AC
79is not found, the behavior is undefined.
80Use either
81.BR strlen (3)
82or
83.BR memchr (3)
84instead.
47297adb 85.SH RETURN VALUE
60a90ecd
MK
86The
87.BR memchr ()
88and
89.BR memrchr ()
90functions return a pointer
fea681da
MK
91to the matching byte or NULL if the character does not occur in
92the given memory area.
847e0d88 93.PP
2a8bb904
MK
94The
95.BR rawmemchr ()
94877d15 96function returns a pointer to the matching byte.
daecb330 97.SH ATTRIBUTES
f92bb4d8
PH
98For an explanation of the terms used in this section, see
99.BR attributes (7).
c466875e
MK
100.ad l
101.nh
f92bb4d8
PH
102.TS
103allbox;
c466875e 104lbx lb lb
f92bb4d8
PH
105l l l.
106Interface Attribute Value
107T{
daecb330
PH
108.BR memchr (),
109.BR memrchr (),
daecb330 110.BR rawmemchr ()
f92bb4d8
PH
111T} Thread safety MT-Safe
112.TE
c466875e
MK
113.hy
114.ad
115.sp 1
3113c7f3 116.SH STANDARDS
4131356c
AC
117.TP
118.BR memchr ()
119C11, POSIX.1-2008.
120.TP
63aa9df0 121.BR memrchr ()
4131356c
AC
122.TQ
123.BR rawmemchr ()
124GNU.
125.SH HISTORY
126.TP
127.BR memchr ()
128POSIX.1-2001, C89, SVr4, 4.3BSD.
129.TP
130.BR memrchr ()
131glibc 2.2.
132.TP
c7cb2bdb 133.BR rawmemchr ()
4131356c 134glibc 2.1.
47297adb 135.SH SEE ALSO
879091c9 136.BR bstring (3),
52aa4b97 137.BR ffs (3),
3924b70d 138.BR memmem (3),
fea681da
MK
139.BR strchr (3),
140.BR strpbrk (3),
141.BR strrchr (3),
142.BR strsep (3),
143.BR strspn (3),
144.BR strstr (3),
145.BR wmemchr (3)