CINXE.COM

memcpy

<html> <head> <title>memcpy</title> <META NAME="KEYWORDS" CONTENT="memcpy"> </head> <body BGCOLOR="#ffffff" LINK="#0000ff" VLINK="#0000ff" ALINK="#0000ff" TEXT="#000000"> <center> <h1><b>memcpy</b></h1></center> <PRE> <STRONG><A HREF="/man3/MEMCPY">MEMCPY(3)</A></STRONG> Linux Programmer's Manual <STRONG><A HREF="/man3/MEMCPY">MEMCPY(3)</A></STRONG> NAME memcpy - copy memory area SYNOPSIS #include &lt;string.h&gt; void *memcpy(void *dest, const void *src, size_t n); DESCRIPTION The memcpy() function copies n bytes from memory area src to memory area dest. The memory areas must not overlap. Use <STRONG><A HREF="/man3/memmove">memmove(3)</A></STRONG> if the memory areas do overlap. RETURN VALUE The memcpy() function returns a pointer to dest. ATTRIBUTES For an explanation of the terms used in this section, see at- <STRONG><A HREF="/man7/tributes">tributes(7)</A></STRONG>. +----------+---------------+---------+ |Interface | Attribute | Value | +----------+---------------+---------+ |memcpy() | Thread safety | MT-Safe | +----------+---------------+---------+ CONFORMING TO POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD. NOTES Failure to observe the requirement that the memory areas do not overlap has been the source of significant bugs. (POSIX and the C standards are explicit that employing memcpy() with overlapping areas produces undefined behavior.) Most notably, in glibc 2.13 a performance opti- mization of memcpy() on some platforms (including x86-64) included changing the order in which bytes were copied from src to dest. This change revealed breakages in a number of applications that per- formed copying with overlapping areas. Under the previous implementa- tion, the order in which the bytes were copied had fortuitously hidden the bug, which was revealed when the copying order was reversed. In glibc 2.14, a versioned symbol was added so that old binaries (i.e., those linked against glibc versions earlier than 2.14) employed a mem- cpy() implementation that safely handles the overlapping buffers case (by providing an "older" memcpy() implementation that was aliased to <STRONG><A HREF="/man3/memmove">memmove(3)</A></STRONG>). SEE ALSO <STRONG><A HREF="/man3/bcopy">bcopy(3)</A></STRONG>, <STRONG><A HREF="/man3/bstring">bstring(3)</A></STRONG>, <STRONG><A HREF="/man3/memccpy">memccpy(3)</A></STRONG>, <STRONG><A HREF="/man3/memmove">memmove(3)</A></STRONG>, <STRONG><A HREF="/man3/mempcpy">mempcpy(3)</A></STRONG>, <STRONG><A HREF="/man3/strcpy">strcpy(3)</A></STRONG>, <STRONG><A HREF="/man3/strncpy">strncpy(3)</A></STRONG>, <STRONG><A HREF="/man3/wmemcpy">wmemcpy(3)</A></STRONG> COLOPHON This page is part of release 5.05 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. 2017-09-15 <STRONG><A HREF="/man3/MEMCPY">MEMCPY(3)</A></STRONG></PRE> <center> <h6>Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2025 <a href="http://www.he.net">Hurricane Electric</a>. All Rights Reserved.</h6></center> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10