memmem

Name

memmem -- locate bytes

Synopsis

#define _GNU_SOURCE
#include <string.h>

void * memmem(const void * haystack, size_t haystacklen, const void * needle, size_t needlelen);

Description

memmem() finds the start of the first occurrence of the byte array referenced by needle of length needlelen in the memory area haystack of length haystacklen.

Return Value

memmem() returns a pointer to the beginning of the byte array, or NULL if the byte array is not found.

Notes

Earlier versions of the C library (prior to glibc 2.1) contained a memmem() with various problems, and application developers should treat this function with care.