strscpy(9) Kernel Developer's Manual strscpy(9)

strscpy - string safe^W truncate copy

Linux kernel

#include <linux/string.h>
ssize_t strscpy(size_t dsize;
                char dst[restrict dsize], const char *restrict src,
                size_t dsize);

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.

On success, the length of the new string is returned.

On error, a negative error code is returned.

The string was truncated.

Linux.

Linux.

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.

strlcpy(3), strcpy(3), string(3)

2026-07-11 Linux man-pages 6.19