Difference between revisions of "c/string/wide/wcscat"
From cppreference.com
m (References; language links) |
m (+C17 ref, fmt) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
}} | }} | ||
{{dcl | since=c99 | | {{dcl | since=c99 | | ||
− | wchar_t *wcscat(wchar_t *restrict dest, const wchar_t *restrict src); | + | wchar_t *wcscat( wchar_t *restrict dest, const wchar_t *restrict src ); |
}} | }} | ||
{{dcl rev end}} | {{dcl rev end}} | ||
{{dcl |num=2| since=c11 | | {{dcl |num=2| since=c11 | | ||
− | errno_t wcscat_s(wchar_t *restrict dest, rsize_t destsz, | + | errno_t wcscat_s( wchar_t *restrict dest, rsize_t destsz, |
− | + | const wchar_t *restrict src ); | |
}} | }} | ||
{{dcl end}} | {{dcl end}} | ||
Line 20: | Line 20: | ||
:* {{tt|src}} or {{tt|dest}} is a null pointer | :* {{tt|src}} or {{tt|dest}} is a null pointer | ||
:* {{tt|destsz}} is zero or greater than {{c|RSIZE_MAX/sizeof(wchar_t)}} | :* {{tt|destsz}} is zero or greater than {{c|RSIZE_MAX/sizeof(wchar_t)}} | ||
− | :* there is no null terminator in the first {{tt|destsz}} | + | :* there is no null terminator in the first {{tt|destsz}} wide characters of {{tt|dest}} |
:* truncation would occur (the available space at the end of {{tt|dest}} would not fit every wide character, including the null terminator, of {{tt|src}}) | :* truncation would occur (the available space at the end of {{tt|dest}} would not fit every wide character, including the null terminator, of {{tt|src}}) | ||
:* overlap would occur between the source and the destination strings | :* overlap would occur between the source and the destination strings | ||
− | : | + | :{{c/ext1 availability|wcscat_s}} |
===Parameters=== | ===Parameters=== | ||
Line 34: | Line 34: | ||
===Return value=== | ===Return value=== | ||
@1@ returns a copy of {{tt|dest}} | @1@ returns a copy of {{tt|dest}} | ||
− | @2@ returns zero on success, returns non-zero on error. Also, on error, writes {{c|L'\0'}} to {{c|dest[0]}} (unless {{tt|dest}} is a null pointer or {{tt|destsz}} is zero or greater than {{c| | + | @2@ returns zero on success, returns non-zero on error. Also, on error, writes {{c|L'\0'}} to {{c|dest[0]}} (unless {{tt|dest}} is a null pointer or {{tt|destsz}} is zero or greater than {{c|RSIZE_MAX/sizeof(wchar_t)}}). |
===Example=== | ===Example=== | ||
Line 57: | Line 57: | ||
===References=== | ===References=== | ||
+ | {{ref std c17}} | ||
+ | {{ref std | section=7.29.4.3.1 | title=The wcscat function | p=315}} | ||
+ | {{ref std | section=K.3.9.2.2.1 | title=The wcscat_s function | p=466}} | ||
+ | {{ref std end}} | ||
{{ref std c11}} | {{ref std c11}} | ||
{{ref std | section=7.29.4.3.1 | title=The wcscat function | p=432}} | {{ref std | section=7.29.4.3.1 | title=The wcscat function | p=432}} | ||
{{ref std | section=K.3.9.2.2.1 | title=The wcscat_s function | p=642-643}} | {{ref std | section=K.3.9.2.2.1 | title=The wcscat_s function | p=642-643}} | ||
+ | {{ref std end}} | ||
{{ref std c99}} | {{ref std c99}} | ||
{{ref std | section=7.24.4.3.1 | title=The wcscat function | p=378}} | {{ref std | section=7.24.4.3.1 | title=The wcscat function | p=378}} | ||
Line 72: | Line 77: | ||
{{dsc end}} | {{dsc end}} | ||
− | + | {{langlinks|ar|cs|de|es|fr|it|ja|ko|pl|pt|ru|tr|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 12:20, 27 June 2022
Defined in header <wchar.h>
|
||
(1) | ||
wchar_t *wcscat( wchar_t *dest, const wchar_t *src ); |
(since C95) (until C99) |
|
wchar_t *wcscat( wchar_t *restrict dest, const wchar_t *restrict src ); |
(since C99) | |
errno_t wcscat_s( wchar_t *restrict dest, rsize_t destsz, const wchar_t *restrict src ); |
(2) | (since C11) |
1) Appends a copy of the wide string pointed to by
src
to the end of the wide string pointed to by dest
. The wide character src[0]
replaces the null terminator at the end of dest
. The resulting wide string is null-terminated. The behavior is undefined if the destination array is not large enough for the contents of both str
and dest
and the terminating null wide character. The behavior is undefined if the strings overlap. 2) Same as (1), except that it may clobber the rest of the destination array (from the last character written to
destsz
) with unspecified values and that the following errors are detected at runtime and call the currently installed constraint handler function:
-
src
ordest
is a null pointer -
destsz
is zero or greater than RSIZE_MAX/sizeof(wchar_t) - there is no null terminator in the first
destsz
wide characters ofdest
- truncation would occur (the available space at the end of
dest
would not fit every wide character, including the null terminator, ofsrc
) - overlap would occur between the source and the destination strings
-
- As with all bounds-checked functions,
wcscat_s
is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including <wchar.h>.
Contents |
[edit] Parameters
dest | - | pointer to the null-terminated wide string to append to |
src | - | pointer to the null-terminated wide string to copy from |
destsz | - | maximum number of characters to write, typically the size of the destination buffer |
[edit] Return value
1) returns a copy of
dest
2) returns zero on success, returns non-zero on error. Also, on error, writes L'\0' to dest[0] (unless
dest
is a null pointer or destsz
is zero or greater than RSIZE_MAX/sizeof(wchar_t)).[edit] Example
Run this code
Output:
Земля, прощай. В добрый путь.
[edit] References
- C17 standard (ISO/IEC 9899:2018):
- 7.29.4.3.1 The wcscat function (p: 315)
- K.3.9.2.2.1 The wcscat_s function (p: 466)
- C11 standard (ISO/IEC 9899:2011):
- 7.29.4.3.1 The wcscat function (p: 432)
- K.3.9.2.2.1 The wcscat_s function (p: 642-643)
- C99 standard (ISO/IEC 9899:1999):
- 7.24.4.3.1 The wcscat function (p: 378)
[edit] See also
(C95)(C11) |
appends a certain amount of wide characters from one wide string to another (function) |
(C11) |
concatenates two strings (function) |
(C95)(C11) |
copies one wide string to another (function) |
C++ documentation for wcscat
|