![]() |
![]() |
![]() |
Copy a number of characters in one string to another
#include <strings.h> void bcopy( const void *src, void *dst, size_t n );
libc
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. |
#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
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
bcmp(), bzero(), memmove(), strcpy()
![]() |
![]() |
![]() |