memcpy
| Buffer Manipulation Functions |
Copies characters from one buffer to another.
void *memcpy( void *dest, const void *src, size_t n );
| dest | Destination buffer where the data is copied. |
| src | The name of the source buffer from which the data is copied. |
| n | The number of bytes to copy. |
The memcpy function copies n characters from the src buffer to the dest buffer.
Return Values
Returns dest, the destination buffer to where the data is copied.
Example
The following example copies the string in s1 to s2.
#include <string.h>
char s1[] = "Sample string";
char s2[40];
/* +1 to include NULL terminator */
memcpy(s2, s1, strlen(s1) + 1); lr_output_message("s1=%s s2=%s", s1, s2);
Example: Output:
s1=Sample string s2=Sample string

