memccpy(3)

memccpy3

Copy bytes until character found

Usage

#include <string.h>

void *

memccpy(void * restrict dst, const void * restrict src, int c, size_t len);

Library

Standard C Library (libc, -lc)

Overview

The memccpy() function copies bytes from object src to object dst. If the character c (as converted to an unsigned char) occurs in the object src, the copy stops and a pointer to the byte after the copy of c in the object dst is returned. Otherwise, len bytes are copied, and a NULL pointer is returned. If src and dst overlap, behavior is undefined.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 42 times.

  1. 2.0.5–2.1.7.1
  2. 2.2.2–3.4
  3. 3.5–3.5.1
  4. 4.0
  5. 4.1–4.4
  6. 4.5–4.11
  7. 5.0–6.3
  8. 6.4
  9. 7.0
  10. 7.1
  11. 7.2
  12. 7.3
  13. 7.4
  14. 8.0
  15. 8.1
  16. 8.2
  17. 8.3
  18. 8.4
  19. 9.0
  20. 9.1
  21. 9.2
  22. 9.3
  23. 10.0
  24. 10.1
  25. 10.2
  26. 10.3
  27. 10.4
  28. 11.0
  29. 11.1
  30. 11.2
  31. 11.3
  32. 11.4
  33. 12.0
  34. 12.1
  35. 12.2
  36. 12.3
  37. 12.4
  38. 13.0–13.2
  39. 13.3–14.0
  40. 14.1–14.3
  41. 14.4–14.5
  42. 15.0–15.1
  43. 16.0

Standards

The memccpy() function conforms to IEEE Std 1003.1-2004 (“POSIX.1”) and ISO/IEC 9899:2024 (“ISO C23”).

History

The memccpy() function first appeared in 4.4BSD and was first specified in the -svid1. The restrict keyword was added to the prototype in FreeBSD 5.0.0 in accordance with the updated specification of IEEE Std 1003.1-2004 (“POSIX.1”).

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.