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

# strncat(3)

nonstring catenate

## NAME

strncat - nonstring catenate

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <string.h>  // see memory.h(3head)
```

**char \*strncat(**size\_t ssize;               **char \*restrict** *dst***, const char** *src***\[restrict** *ssize***\],**               **size\_t** *ssize***);**

## DESCRIPTION

This function appends at most *ssize* non-null bytes from the array pointed to by *src*, followed by a null character, to the end of the string pointed to by *dst*. *dst* must point to a string contained in a buffer that is large enough, that is, the buffer size must be at least *strlen(dst) + strnlen(src, ssize) + 1*.

It is equivalent to

```
stpcpy(mempcpy(strnul(dst), src, strnlen(src, ssize)), ""), dst
```

## RETURN VALUE

**strncat**() returns *dst*.

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **strncat**() | Thread safety | MT-Safe |

## STANDARDS

C11, POSIX.1-2008.

## HISTORY

POSIX.1-2001, C89, SVr4, 4.3BSD.

## CAVEATS

The name of this function is confusing:

- •

  It has no relation to [**strncpy**(3)](/strncpy/3.md).

- •

  It doesn't truncate the input nonstring.

If the destination buffer does not already contain a string, or is not large enough, the behavior is undefined. See **\_FORTIFY\_SOURCE** in [**feature\_test\_macros**(7)](/feature_test_macros/7.md).

## EXAMPLES

```
#include <stdcountof.h>
#include <stdio.h>
#include <string.h>
#include <utmp.h>
void print_ut_user(struct utmp *ut);
void
print_ut_user(struct utmp *ut)
{
	char  buf[countof(ut->ut_user) + 1];
	strcpy(buf, "");
	strncat(buf, ut->ut_user, countof(ut->ut_user));
	puts(buf);
}
```

## SEE ALSO

[**memory.h**(3head)](/memory.h/3head.md), [**string\_copying**(7)](/string_copying/7.md)
