#include <string.h> void *memccpy(void *restrict s1, const void *restrict s2, int c, size_t);
void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);
#include <string.h> const void *memchr(const void *s, int c, size_t n);
#include <cstring> void *std::memchr(void *s, int c, size_t n);
These functions operate as efficiently as possible on memory areas (arrays of bytes bounded by a count, not terminated by a null character). They do not check for the overflow of any receiving memory area.
The memccpy() function copies bytes from memory area s2 into s1, stopping after the first occurrence of c (converted to an unsigned char) has been copied, or after n bytes have been copied, whichever comes first. It returns a pointer to the byte after the copy of c in s1, or a null pointer if c was not found in the first n bytes of s2..
The memmem() function locates the start of the first occurrence of the substring needle of length needlelen in the memory area haystack of length haystacklen. It returns a pointer to the start of the substring, or NULL if the substring is not found.
Using memcpy() might be faster than using memmove() if the application knows that the objects being copied do not overlap.
See attributes(5) for descriptions of the following attributes:
string(3C), attributes(5), standards(5)
Overlap between objects being copied can arise even when their (virtual) address ranges appear to be disjoint; for example, as a result of memory-mapping overlapping portions of the same underlying file, or of attaching the same shared memory segment more than once.