logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

memmem - locate a substring

Attributes

       For an explanation of the terms used in this section, see attributes(7).
       ┌─────────────────────────────────────────────────────────────────────────────┬───────────────┬─────────┐
       │ InterfaceAttributeValue   │
       ├─────────────────────────────────────────────────────────────────────────────┼───────────────┼─────────┤
       │ memmem()                                                                    │ Thread safety │ MT-Safe │
       └─────────────────────────────────────────────────────────────────────────────┴───────────────┴─────────┘

Bugs

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

Description

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

History

       musl libc 0.9.7; FreeBSD 6.0, OpenBSD 5.4, NetBSD, Illumos.

Library

       Standard C library (libc, -lc)

Name

       memmem - locate a substring

Return Value

       The  memmem()  function  returns a pointer to the beginning of the substring, or NULL if the substring is
       not found.

See Also

bstring(3), strstr(3)

Linux man-pages 6.9.1                              2024-05-02                                          memmem(3)

Standards

       None.

Synopsis

#define_GNU_SOURCE         /* See feature_test_macros(7) */
       #include<string.h>void*memmem(constvoidhaystack[.haystacklen],size_thaystacklen,constvoidneedle[.needlelen],size_tneedlelen);

See Also