NAME
memmem – locate a byte subsequence in a byte sequence
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <string.h>
QVoid *
memmem(QVoid *big, size_t big_len, const void *little, size_t little_len);
DESCRIPTION
The memmem() function locates the first occurrence of the byte sequence little in the byte sequence big.
RETURN VALUES
If little_len is zero big is returned (that is, an empty little is deemed to match at the beginning of big); if little occurs nowhere in big, NULL is returned; otherwise a pointer to the first character of the first occurrence of little is returned.
SEE ALSO
STANDARDS
memmem() conforms to IEEE Std 1003.1-2024 (“POSIX.1”). Like the qualifier-preserving functions in ISO/IEC 9899:2024 (“ISO C23”), FreeBSD implements memmem() as qualifier-preserving as well.
HISTORY
The memmem() function first appeared in FreeBSD 6.0. It was replaced with an optimized O(n) implementation from the musl libc project in FreeBSD 12.0. Pascal Gloor ⟨[email protected]⟩ provided this man page along with the previous implementation.
BUGS
This function was broken in Linux libc up to and including version 5.0.9 and in GNU libc prior to version 2.1. Prior to FreeBSD 11.0 memmem returned NULL when little_len equals 0.