To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source.
Parameters
- destination
- Pointer to the destination array where the content is to be copied.
- source
- C string to be copied.
Return Value
destination is returned.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Output:
str1: Sample string str2: Sample string str3: copy successful |
See also
| strncpy | Copy characters from string (function) |
| memcpy | Copy block of memory (function) |
| memmove | Move block of memory (function) |
| memchr | Locate character in block of memory (function) |
| memcmp | Compare two blocks of memory (function) |
| memset | Fill block of memory (function) |
