---
name: "memmem"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/memmem"
---

# memmem(3)

locate a byte subsequence in a byte sequence

## 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

[memchr(3)](/memchr/3.md), [strchr(3)](/strchr/3.md), [strstr(3)](/strstr/3.md)

## 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 ⟨*pascal.gloor@spale.com*⟩ 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.
