memccpy() — Copy bytes in memory


Standards / Extensions C or C++ Dependencies
Single UNIX Specification, Version 3


#include <string.h>

void *memccpy(void *__restrict__ s1, const void *__restrict__ s2, int c, size_t n);

General description

The memccpy() function copies bytes from memory area s2 into memory area s1, stopping after the first occurrence of byte c (converted to an unsigned char) is copied, or after n bytes are copied, whichever comes first.

Returned value

If successful, memccpy() returns a pointer to the byte after the copy of c in s1.

If c was not found in the first n bytes of s2, memccpy() returns a NULL pointer.

Related information