December 2005
Beginner to intermediate
618 pages
20h 19m
English
memcpy
Copies the contents of a memory block
#include <string.h> void *memcpy( void * restrictdest, const void * restrictsrc, size_tn);
The memcpy() function
copies n successive bytes beginning at
the address in src to the location
beginning at the address in dest. The
return value is the same as the first argument,
dest. The two pointer values must be at
least n bytes apart, so that the source
and destination blocks do not overlap; otherwise, the function’s
behavior is undefined. For overlapping blocks, use memmove().
typedef struct record {
char name[32];
double data;
struct record *next, *prev;
} Rec_t;
Rec_t template = { "Another fine product", -0.0, NULL, NULL };
Rec_t *tmp_new;
if (( tmp_new = malloc( sizeof(Rec_t) )) != NULL )memcpy( tmp_new, &template, sizeof(Rec_t) );
else
fprintf( stderr, "Out of memory!\n" ), return -1;strcpy(), strncpy(), memove(), wmemcpy(), wmemmove()
Read now
Unlock full access