Names specified here
Name Description Notes Source Availability
strcat() Catenate strings (·) <string.h> C89 C90 C95 C99 C11
strcat_s() Catenate strings ? (·) <string.h> C11
strcpy() Copy string (·) <string.h> C89 C90 C95 C99 C11
strcpy_s() Copy string ? (·) <string.h> C11
strncat() Catenate strings (·) <string.h> C89 C90 C95 C99 C11
strncat_s() Catenate strings ? (·) <string.h> C11
strncpy() Copy string (·) <string.h> C89 C90 C95 C99 C11
strncpy_s() Copy string ? (·) <string.h> C11
wcscat() Catenate wide-character strings (·) <wchar.h> C95 C99 C11
wcscat_s() Catenate wide-character strings ? (·) <wchar.h> C11
wcscpy() Copy wide-character string (·) <wchar.h> C95 C99 C11
wcscpy_s() Copy wide-character string ? (·) <wchar.h> C11
wcsncat() Catenate wide-character strings (·) <wchar.h> C95 C99 C11
wcsncat_s() Catenate wide-character strings ? (·) <wchar.h> C11
wcsncpy() Copy wide-character string (·) <wchar.h> C95 C99 C11
wcsncpy_s() Copy wide-character string ? (·) <wchar.h> C11

Functions with names matching ^(str|wcs)[a-z] might be added to <string.h>, and ^wcs[a-z] might be added to <wchar.h>.

#include <stdio.h>
char *strcpy(char *dst, const char *src);
char *strncpy(char *dst, const char *src, size_t n);
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
errno_t strcpy_s(char *dst, rsize_t dstmax, const char *src);
errno_t strncpy_s(char *dst, rsize_t dstmax, const char *src, rsize_t n);
#include <wchar.h>
wchar_t *wcscpy(wchar_t *dst, const wchar_t *src);
wchar_t *wcsncpy(wchar_t *dst, const wchar_t *src, size_t n);
#define __STDC_WANT_LIB_EXT1__ 1
#include <wchar.h>
errno_t wcscpy_s(wchar_t *dst, rsize_t dstmax, const wchar_t *src);
errno_t wcsncpy_s(wchar_t *dst, rsize_t dstmax, const wchar_t *src, rsize_t n);

The strcpy family of functions copy a null-terminated string from src to an array dst, including the null terminator.

The functions with a parameter n copy at most n characters, so their src strings need not be null-terminated, and the result in dst might not be null-terminated. They also continue write exactly n characters by padding with nulls.

The _s variants fail if more than dstmax characters would have to be copied, or if dstmax or n is greater than RSIZE_MAX, returning non-zero. They also ensure that a null character terminates the result in dst, and place it at the start when failing. The other functions return dst.

#include <stdio.h>
char *strcat(char *dst, const char *src);
char *strncat(char *dst, const char *src, size_t n);
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
errno_t strcat_s(char *dst, rsize_t dstmax, const char *src);
errno_t strncat_s(char *dst, rsize_t dstmax, const char *src, rsize_t n);
#include <wchar.h>
wchar_t *wcscat(wchar_t *dst, const wchar_t *src);
wchar_t *wcsncat(wchar_t *dst, const wchar_t *src, size_t n);
#define __STDC_WANT_LIB_EXT1__ 1
#include <wchar.h>
errno_t wcscat_s(wchar_t *dst, rsize_t dstmax, const wchar_t *src);
errno_t wcsncat_s(wchar_t *dst, rsize_t dstmax, const wchar_t *src, rsize_t n);

The strcat family of functions do the same as their counterparts in the strcpy family, except that dst must be a null-terminated string on input. These functions find the null terminator, and then perform a copy starting at that point, overwriting the original null terminator, thereby appending the string src onto the end of string dst. dstmax is reduced to account for the string already present in dst.


CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2022-06-17T21:43:05.000+0000