1memmem(3) Library Functions Manual memmem(3)
2
3
4
6 memmem - locate a substring
7
9 Standard C library (libc, -lc)
10
12 #define _GNU_SOURCE /* See feature_test_macros(7) */
13 #include <string.h>
14
15 void *memmem(const void haystack[.haystacklen], size_t haystacklen,
16 const void needle[.needlelen], size_t needlelen);
17
19 The memmem() function finds the start of the first occurrence of the
20 substring needle of length needlelen in the memory area haystack of
21 length haystacklen.
22
24 The memmem() function returns a pointer to the beginning of the sub‐
25 string, or NULL if the substring is not found.
26
28 For an explanation of the terms used in this section, see at‐
29 tributes(7).
30
31 ┌────────────────────────────────────────────┬───────────────┬─────────┐
32 │Interface │ Attribute │ Value │
33 ├────────────────────────────────────────────┼───────────────┼─────────┤
34 │memmem() │ Thread safety │ MT-Safe │
35 └────────────────────────────────────────────┴───────────────┴─────────┘
36
38 None.
39
41 musl libc 0.9.7; FreeBSD 6.0, OpenBSD 5.4, NetBSD, Illumos.
42
44 In glibc 2.0, if needle is empty, memmem() returns a pointer to the
45 last byte of haystack. This is fixed in glibc 2.1.
46
48 bstring(3), strstr(3)
49
50
51
52Linux man-pages 6.05 2023-07-20 memmem(3)