strcat() — Concatenate Strings

Format

#include <string.h>

char *strcat(char * __restrict__string1, const char * __restrict__string2);

General Description

The strcat() built-in function concatenates string2 with string1 and ends the resulting string with the NULL character. In other words, strcat() appends a copy of the string pointed to by string2—including the terminating NULL byte— to the end of a string pointed to by string1, with its last byte (that is, the terminating NULL byte of string1) overwritten by the first byte of the appended string.

Do not use a literal string for a string1 value, although string2 may be a literal string.

If the storage of string1 overlaps the storage of string2, the behavior is undefined.

Returned Value

The strcat() built-in function returns the value of string1, the concatenated string.

Related Information