Updated: April 19, 2023 |
Copy a fixed-length string and return a pointer to the end of the result
#include <string.h> char * stpncpy( char * restrict dst, const char * restrict src, size_t num);
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The strncpy() function copies no more than num characters from the string pointed to by src into the array pointed to by dst. If the string pointed to by src is shorter than num characters, null characters are appended to the copy in the array pointed to by dst, until num characters in all have been written. If the string pointed to by src is longer than num characters, then the result isn't terminated by a null character.
If a NUL character is written to the destination, stpncpy() returns the address of the first such NUL character. Otherwise, it returns &dst[num].
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |