---
name: "bson_strncpy"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_strncpy"
---

# bson\_strncpy(3)

## SYNOPSIS

```
void
bson_strncpy (char *dst, const char *src, size_t size);
```

## PARAMETERS

- •

  **dst**: The destination buffer.

- •

  **src**: The src buffer.

- •

  **size**: The number of bytes to copy into dst, which must be at least that size.

## DESCRIPTION

Copies up to **size** bytes from **src** into **dst**. **dst** must be at least **size** bytes in size. A trailing **\\0** is always set.

Does nothing if **size** is zero.

**bson\_strncpy** matches the behavior of the C11 standard **strncpy\_s**, rather than **strncpy**. This means that **bson\_strncpy** always writes a null terminator to **dst**, even if **dst** is too short to fit the entire string from **src**. If there is additional space left in **dst** after copying **src**, **bson\_strncpy** does not fill the remaining space with null characters.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
