]>
Commit | Line | Data |
---|---|---|
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. |
4c1c5274 | 10 | .TH memmem 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
11 | .SH NAME |
12 | memmem \- locate a substring | |
9ec042f6 AC |
13 | .SH LIBRARY |
14 | Standard 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 |
c64cd13e AC |
21 | .BI "void *memmem(const void " haystack [. haystacklen "], size_t " haystacklen , |
22 | .BI " const void " needle [. needlelen "], size_t " needlelen ); | |
fea681da MK |
23 | .fi |
24 | .SH DESCRIPTION | |
60a90ecd MK |
25 | The |
26 | .BR memmem () | |
27 | function finds the start of the first occurrence | |
c6fa0841 | 28 | of the substring |
1ae6b2c7 | 29 | .I needle |
c6fa0841 MK |
30 | of length |
31 | .I needlelen | |
32 | in the memory | |
33 | area | |
34 | .I haystack | |
35 | of length | |
36 | .IR haystacklen . | |
47297adb | 37 | .SH RETURN VALUE |
60a90ecd MK |
38 | The |
39 | .BR memmem () | |
40 | function returns a pointer to the beginning of the | |
fea681da | 41 | substring, or NULL if the substring is not found. |
34a07418 | 42 | .SH ATTRIBUTES |
346143cd PH |
43 | For 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 |
48 | allbox; | |
c466875e | 49 | lbx lb lb |
346143cd PH |
50 | l l l. |
51 | Interface Attribute Value | |
52 | T{ | |
34a07418 | 53 | .BR memmem () |
346143cd PH |
54 | T} Thread safety MT-Safe |
55 | .TE | |
c466875e MK |
56 | .hy |
57 | .ad | |
58 | .sp 1 | |
3113c7f3 | 59 | .SH STANDARDS |
1b238553 | 60 | This function is not specified in POSIX.1, |
c39de556 AC |
61 | but is present on a number of other systems, |
62 | including: | |
63 | musl libc 0.9.7; | |
64 | FreeBSD 6.0, OpenBSD 5.4, NetBSD, and Illumos. | |
fea681da | 65 | .SH BUGS |
b5a620f8 MK |
66 | .\" This function was broken in Linux libraries up to and including libc 5.0.9; |
67 | .\" there the | |
68 | .\" .IR needle | |
69 | .\" and | |
70 | .\" .I haystack | |
71 | .\" arguments were interchanged, | |
72 | .\" and a pointer to the end of the first occurrence of | |
73 | .\" .I needle | |
74 | .\" was returned. | |
ef4f4031 | 75 | .\" |
b5a620f8 MK |
76 | .\" Both old and new libc's have the bug that if |
77 | .\" .I needle | |
78 | .\" is empty, | |
79 | .\" .I haystack\-1 | |
80 | .\" (instead of | |
81 | .\" .IR haystack ) | |
82 | .\" is returned. | |
6e76df0d MK |
83 | In glibc 2.0, if |
84 | .I needle | |
85 | is empty, | |
86 | .BR memmem () | |
87 | returns a pointer to the last byte of | |
c6fa0841 | 88 | .IR haystack . |
ca7b3c18 | 89 | This is fixed in glibc 2.1. |
47297adb | 90 | .SH SEE ALSO |
879091c9 | 91 | .BR bstring (3), |
0a4f8b7b | 92 | .BR strstr (3) |