]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/memmem.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / memmem.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
4.\"
5.\" References consulted:
6.\" Linux libc source code
7.\" 386BSD man pages
8.\" Modified Sat Jul 24 18:50:48 1993 by Rik Faith (faith@cs.unc.edu)
2b0fa182 9.\" Interchanged 'needle' and 'haystack'; added history, aeb, 980113.
45186a5d 10.TH MEMMEM 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
11.SH NAME
12memmem \- locate a substring
9ec042f6
AC
13.SH LIBRARY
14Standard C library
8fc3b2cf 15.RI ( libc ", " \-lc )
fea681da
MK
16.SH SYNOPSIS
17.nf
b80f966b 18.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
fea681da 19.B #include <string.h>
68e4db0a 20.PP
fea681da 21.BI "void *memmem(const void *" haystack ", size_t " haystacklen ,
088a639b 22.BI " const void *" needle ", size_t " needlelen );
fea681da
MK
23.fi
24.SH DESCRIPTION
60a90ecd
MK
25The
26.BR memmem ()
27function finds the start of the first occurrence
c6fa0841 28of the substring
1ae6b2c7 29.I needle
c6fa0841
MK
30of length
31.I needlelen
32in the memory
33area
34.I haystack
35of length
36.IR haystacklen .
47297adb 37.SH RETURN VALUE
60a90ecd
MK
38The
39.BR memmem ()
40function returns a pointer to the beginning of the
fea681da 41substring, or NULL if the substring is not found.
34a07418 42.SH ATTRIBUTES
346143cd
PH
43For an explanation of the terms used in this section, see
44.BR attributes (7).
c466875e
MK
45.ad l
46.nh
346143cd
PH
47.TS
48allbox;
c466875e 49lbx lb lb
346143cd
PH
50l l l.
51Interface Attribute Value
52T{
34a07418 53.BR memmem ()
346143cd
PH
54T} Thread safety MT-Safe
55.TE
c466875e
MK
56.hy
57.ad
58.sp 1
3113c7f3 59.SH STANDARDS
1b238553
MK
60This function is not specified in POSIX.1,
61but is present on a number of other systems.
fea681da 62.SH BUGS
b5a620f8
MK
63.\" This function was broken in Linux libraries up to and including libc 5.0.9;
64.\" there the
65.\" .IR needle
66.\" and
67.\" .I haystack
68.\" arguments were interchanged,
69.\" and a pointer to the end of the first occurrence of
70.\" .I needle
71.\" was returned.
ef4f4031 72.\"
b5a620f8
MK
73.\" Both old and new libc's have the bug that if
74.\" .I needle
75.\" is empty,
76.\" .I haystack\-1
77.\" (instead of
78.\" .IR haystack )
79.\" is returned.
6e76df0d
MK
80In glibc 2.0, if
81.I needle
82is empty,
83.BR memmem ()
84returns a pointer to the last byte of
c6fa0841 85.IR haystack .
ca7b3c18 86This is fixed in glibc 2.1.
47297adb 87.SH SEE ALSO
879091c9 88.BR bstring (3),
0a4f8b7b 89.BR strstr (3)