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
26       attributes(7).
27
28       ┌──────────┬───────────────┬─────────┐
29Interface Attribute     Value   
30       ├──────────┼───────────────┼─────────┤
31memmem()  │ Thread safety │ MT-Safe │
32       └──────────┴───────────────┴─────────┘

CONFORMING TO

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

BUGS

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

SEE ALSO

42       bstring(3), strstr(3)
43

COLOPHON

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