---
name: "strscpy"
section: "9"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/strscpy"
---

# strscpy(9)

string safe^W truncate copy

## 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

[**strlcpy**(3)](/strlcpy/3.md), [**strcpy**(3)](/strcpy/3.md), [**string**(3)](/string/3.md)
