MEMCCPY(3POSIX)

πŸ’– MEMCCPY(3POSIX) β€” like, the POSIX Programmer's Manual era πŸ’–

okay bestie, real talk before we even start: this page is part of the POSIX Programmer's Manual, and the Linux version of this interface may literally do its own thing (so pls go check the corresponding Linux man page for the Linux behavior), OR β€” plot twist β€” the interface might not even be implemented on Linux at all. πŸ™ˆ


✨ NAME ✨

memccpy β€” copy bytes in memory. that's it, that's the whole job. πŸ’…


🌸 SYNOPSIS 🌸

#include <string.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so memccpy() shall copy bytes from the memory area s2 into s1, and it stops after the first occurrence of byte c (converted to an unsigned char) gets copied β€” or after n bytes are copied, whichever one comes first. first one to the finish line wins, periodt. 🏁

⚠️ but if copying happens between objects that overlap? the behavior is undefined. like, we do not know her. don't do it. no cap. πŸ’€

πŸ‘‘ RETURN VALUE πŸ‘‘

memccpy() shall return a pointer to the byte after the copy of c in s1. and if c was not found in the first n bytes of s2? you get a null pointer. sad girl hours, honestly. 😭


πŸŽ€ ERRORS πŸŽ€

no errors are defined. she simply does not have problems. ✨

the following sections are informative, iykyk.


πŸ“ EXAMPLES πŸ“

None. (nothing here, move along bestie, the vibes are minimal πŸ’€)


🌈 APPLICATION USAGE 🌈

heads up: memccpy() does not check for the overflow of the receiving memory area. she trusts you. maybe too much. 🫢 so pls be careful, okay?


🧚 RATIONALE 🧚

None. iconic of her to say nothing. πŸ‘‘


⭐ FUTURE DIRECTIONS ⭐

None. the future is... also nothing. slay. πŸ’…


πŸ’œ SEE ALSO πŸ’œ

  • The Base Definitions volume of POSIX.1‐2017, <string.h>

portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! 🫢 this masterpiece was brought to you by IEEE/The Open Group, 2017, filed under MEMCCPY(3POSIX). go forth and copy bytes responsibly, mwah πŸ’–βœ¨