The Open Group Base Specifications Issue 8
IEEE Std 1003.1-2024
Copyright © 2001-2024 The IEEE and The Open Group

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.

 

return to top of page

UNIX® is a registered Trademark of The Open Group.
POSIX™ is a Trademark of The IEEE.
Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved
[ Main Index | XBD | XSH | XCU | XRAT ]