bcopy()

Copy a number of characters in one string to another

Synopsis:

#include <strings.h>

void bcopy( const void *src,
            void *dst,
            size_t n );

Arguments:

src
The string you want to copy.
dst
An existing array into which you want to copy the string.
n
The number of bytes to copy.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The bcopy() function copies the byte string pointed to by src (including any NUL characters) into the array pointed to by dst. The number of bytes to copy is specified by n. Copying of overlapping objects is guaranteed to work properly.


Note: This function is similar to the ANSI memmove() function, but the order of arguments is different. New code should use the ANSI function.

Examples:

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

int main( void )
  {
    auto char buffer[80];

    bcopy( "Hello ", buffer, 6 );
    bcopy( "world",  &buffer[6], 6 );
    printf( "%s\n", buffer );
    return EXIT_SUCCESS;
  }

produces the output:

Hello world

Classification:

POSIX 1003.1 XSI

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

bcmp(), bzero(), memmove(), strcpy()