- Function
Copy part of a string.
- Header
- Declaration
char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);- Description
The
strncpyfunction copies not more than n bytes from the array pointed to bys2to the array pointed to bys1. If the array pointed to bys2is a string that is shorter than n bytes, null bytes are appended to the copy in the array pointed to bys1, untilnbytes are written. The function will always returns1.- Limits
- The function is only available as fastcall function, so it may only be used in presence of a prototype. If there is no null byte in the first
nbytes of the array pointed to bys2, the result is not null-terminated.- If copying takes place between objects that overlap, the behavior is undefined.
- Availability
ISO 9899
- See also
- Example
#include <string.h> static char hello[6]; strcpy (hello, "Hello world!\n", sizeof (hello) - 1); hello[5] = '\0';