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 );

Since:

BlackBerry 10.0.0

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.

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

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus