[Previous]
[Contents]
[Next]

memcpy(), _fmemcpy()

copy a number of characters from one buffer to another

Synopsis:

#include <string.h>
void *memcpy( void *dst,
              const void *src,
              size_t length );
void __far *_fmemcpy( void __far *dst,
                      const void __far *src,
                      size_t length );

Description:

The memcpy() function copies length characters from the buffer pointed to by src into the buffer pointed to by dst.


Note: Copying of overlapping objects isn't guaranteed to work properly. See the memmove() function if you wish to copy objects that overlap.

The _fmemcpy() function is a data-model-independent form of the memcpy() function. It accepts far pointer arguments, and returns a far pointer. It is most useful in mixed memory model applications.

Returns:

A pointer to the destination buffer (that is, the value of dst).

Examples:

#include <stdio.h>
#include <string.h>

void main()
  {
    char buffer[80];

    memcpy( buffer, "Hello", 5 );
    buffer[5] = '\0';
    printf( "%s\n", buffer );
  }

Classification:

memcpy() is ANSI; _fmemcpy() is WATCOM.
Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

memchr(), memcmp(), memicmp(), memmove(), memset()


[Previous]
[Contents]
[Next]