Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can also prefer the memcpy() function. </p> <pre><code>void * memcpy ( void * destination, const void * source, size_t num ); </code></pre> <p><code>destination</code> Pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.</p> <p><code>source</code> Pointer to the source of data to be copied, type-casted to a pointer of type const void*.</p> <p><code>num</code> Number of bytes to copy.</p> <p><code>size_t</code> is an unsigned integral type.</p> <p>Copies the values of num bytes from the location pointed by source directly to the memory block pointed by destination.</p> <p>The underlying type of the objects pointed by both the source and destination pointers are irrelevant for this function; The result is a binary copy of the data.</p> <p>The function does not check for any terminating null character in source - it always copies exactly num bytes.</p> <p>To avoid overflows, the size of the arrays pointed by both the destination and source parameters, shall be at least num bytes, and should not overlap (for overlapping memory blocks, memmove is a safer approach).</p> <p>Sample Program</p> <pre><code>/* memcpy example */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; struct { char name[40]; int age; } person, person_copy; int main () { char myname[] = "user613994"; /* using memcpy to copy string: */ memcpy ( person.name, myname, strlen(myname)+1 ); person.age = 46; /* using memcpy to copy structure: */ memcpy ( &amp;person_copy, &amp;person, sizeof(person) ); printf ("person_copy: %s, %d \n", person_copy.name, person_copy.age ); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload