1MEMMEM(3)                  Linux Programmer's Manual                 MEMMEM(3)
2
3
4

NAME

6       memmem - locate a substring
7

SYNOPSIS

9       #define _GNU_SOURCE         /* See feature_test_macros(7) */
10       #include <string.h>
11
12       void *memmem(const void *haystack, size_t haystacklen,
13                    const void *needle, size_t needlelen);
14

DESCRIPTION

16       The  memmem()  function  finds the start of the first occurrence of the
17       substring needle of length needlelen in the  memory  area  haystack  of
18       length haystacklen.
19

RETURN VALUE

21       The  memmem()  function  returns a pointer to the beginning of the sub‐
22       string, or NULL if the substring is not found.
23

ATTRIBUTES

25       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
26       tributes(7).
27
28       ┌────────────────────────────────────────────┬───────────────┬─────────┐
29Interface                                   Attribute     Value   
30       ├────────────────────────────────────────────┼───────────────┼─────────┤
31memmem()                                    │ Thread safety │ MT-Safe │
32       └────────────────────────────────────────────┴───────────────┴─────────┘
33

CONFORMING TO

35       This  function  is not specified in POSIX.1, but is present on a number
36       of other systems.
37

BUGS

39       In glibc 2.0, if needle is empty, memmem() returns  a  pointer  to  the
40       last byte of haystack.  This is fixed in glibc 2.1.
41

SEE ALSO

43       bstring(3), strstr(3)
44

COLOPHON

46       This  page  is  part of release 5.13 of the Linux man-pages project.  A
47       description of the project, information about reporting bugs,  and  the
48       latest     version     of     this    page,    can    be    found    at
49       https://www.kernel.org/doc/man-pages/.
50
51
52
53GNU                               2021-03-22                         MEMMEM(3)
Impressum