table of contents
| strscpy(9) | Kernel Developer's Manual | strscpy(9) |
NAME¶
strscpy - string safe^W truncate copy
LIBRARY¶
Linux kernel
SYNOPSIS¶
#include <linux/string.h>
ssize_t strscpy(size_t dsize;
char dst[restrict dsize], const char *restrict src,
size_t dsize);
DESCRIPTION¶
This function copies the string pointed to by src, into a string at the buffer pointed to by dst.
If the string doesn't fit in the buffer, it is truncated.
RETURN VALUE¶
On success, the length of the new string is returned.
On error, a negative error code is returned.
ERRORS¶
- -E2BIG
- The string was truncated.
STANDARDS¶
Linux.
HISTORY¶
Linux.
CAVEATS¶
The "s" in the name of this function refers to safety, but safety is a relative term that doesn't always apply to this function. A more appropriate name for this function would reflect what it does, which is copying a string with truncation. Some projects call this function strtcpy().
This function is not provided by any libc, so user-space programmers must implement it themselves.
SEE ALSO¶
| 2026-07-11 | Linux man-pages (unreleased) |