Difference between revisions of "GDN:memcpy"

From LibrePlanet
Jump to: navigation, search
(Created page with "{{Infobox Function | header = string.h | since = C90 }} The memcpy function copies size bytes from the object beginning at from into the object beginning at to. The beh...")
 
m (moved GDN: memcpy to GDN:memcpy: Remove accidental source)
 
(One intermediate revision by the same user not shown)
Line 13: Line 13:
  
 
<source lang="c">void * memcpy (void *restrict to, const void *restrict from, size_t size)</source>
 
<source lang="c">void * memcpy (void *restrict to, const void *restrict from, size_t size)</source>
 +
 +
==Example==
 +
 +
<source lang="c">
 +
struct foo *oldarray, *newarray;
 +
          int arraysize;
 +
          ...
 +
          memcpy (new, old, arraysize * sizeof (struct foo));
 +
</source>

Latest revision as of 15:26, 30 October 2013


The memcpy function copies size bytes from the object beginning at from into the object beginning at to. The behavior of this function is undefined if the two arrays to and from overlap; use memmove instead if overlapping is possible.

The value returned by memcpy is the value of to.

Prototype

<source lang="c">void * memcpy (void *restrict to, const void *restrict from, size_t size)</source>

Example

<source lang="c"> struct foo *oldarray, *newarray;

         int arraysize;
         ...
         memcpy (new, old, arraysize * sizeof (struct foo));

</source>

GDN:memcpy
Header string.h
Supported Since C90