Keil Logo


#include <string.h>

void *memccpy (
  void *dest,          /* destination buffer */
  const void *src,     /* source buffer */
  char c,              /* character which ends copy */
  unsigned int len);   /* maximum bytes to copy */

The memccpy function copies 0 or more characters from src to dest. Characters are copied until the character c is copied or until len bytes have been copied, whichever comes first.

Return Value

The memccpy function returns a pointer to the byte in dest that follows the last character copied or a null pointer if the last character copied was c.

See Also

memchr, memcmp, memcpy, memmove, memset

#include <string.h>
#include <stdio.h> /* for printf */

void tst_memccpy (void) {
  char src1 [100] = "Copy this string to dst1";
  char dst1 [100];
  void *c;

  c = memccpy (dst1, src1, 'g', sizeof (dst1));

  if (c == NULL)
    printf ("'g' was not found in the src buffer\n");
    printf ("characters copied up to 'g'\n");
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.