NAME

memmem — find a byte subsequence in a byte sequence

SYNOPSIS

[CX] [Option Start] #include <string.h>

void *memmem(const void *
haystack, size_t haystacklen,
       const void *
needle, size_t needlelen); [Option End]

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.


The following sections are informative.

EXAMPLES

None.

APPLICATION USAGE

None.

RATIONALE

This function is similar to strstr(), except that NUL bytes may be included in either needle or haystack.

FUTURE DIRECTIONS

None.

SEE ALSO

memchr , strstr

XBD <string.h>

CHANGE HISTORY

First released in Issue 8.

End of informative text.