MEMMEM(3) Library Functions Manual MEMMEM(3)
NAME
memmem — find a
byte subsequence in a byte sequence
SYNOPSIS
void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
DESCRIPTION
The memmem () function shall locate the
first occurrence of byte sequence needle of length
needlelen in byte sequence haystack of
length haystacklen.
RETURN VALUE
Upon successful completion, memmem ()
shall return a pointer to the the first byte of the located byte sequence in
haystack, or a null pointer if the byte sequence is not
found.
If needlelen is zero, the function shall return haystack.
If haystacklen is less than needlelen, the function shall return a null pointer.
ERRORS
No errors are defined.
EXAMPLES
None.
APPLICATION USAGE
None.
RATIONALE
This function is similar to strstr(3), except that NUL bytes may be included in either needle or haystack.
FUTURE DIRECTIONS
None.
SEE ALSO
XBD <string.h>
CHANGE HISTORY
First released in Issue 8.
June 14, 2024 posix.fail