memccpy() — Copy bytes in memory

Standards

Standards / Extensions C or C++ Dependencies
XPG4
XPG4.2
Single UNIX Specification, Version 3
both  

Format

#define _XOPEN_SOURCE
#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