]>
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. |
45186a5d | 10 | .TH MEMMEM 3 2021-03-22 "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 |
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 |
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 MK |
60 | This function is not specified in POSIX.1, |
61 | but 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 |
80 | In glibc 2.0, if |
81 | .I needle | |
82 | is empty, | |
83 | .BR memmem () | |
84 | returns a pointer to the last byte of | |
c6fa0841 | 85 | .IR haystack . |
ca7b3c18 | 86 | This is fixed in glibc 2.1. |
47297adb | 87 | .SH SEE ALSO |
879091c9 | 88 | .BR bstring (3), |
0a4f8b7b | 89 | .BR strstr (3) |