Copy a number of characters in one string to another
#include <strings.h> void bcopy( const void *src, void *dst, size_t n );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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.
#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
Standard Unix; removed from POSIX.1-2008
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |