wcsncat, wcsncat_s
Defined in header
<wchar.h>
|
||
(1) | ||
wchar_t
*
wcsncat
(
wchar_t
*
dest,
const
wchar_t
*
src,
size_t
count
)
;
|
(since C95)
(until C99) |
|
wchar_t
*
wcsncat
(
wchar_t
*
restrict
dest,
const wchar_t * restrict src, size_t count ) ; |
(since C99) | |
errno_t wcsncat_s
(
wchar_t
*
restrict
dest, rsize_t destsz,
const wchar_t * restrict src, rsize_t count ) ; |
(2) | (since C11) |
count
wide characters from the wide string pointed to by
src
, stopping if the null terminator is copied, to the end of the character string pointed to by
dest
. The wide character
src
[
0
]
replaces the null terminator at the end of
dest
. The null terminator is always appended in the end (so the maximum number of wide characters the function may write is
count
+
1
).
str
and
dest
and the terminating null wide character.
destsz
) and that the following errors are detected at runtime and call the currently installed
constraint handler
function:
-
-
src
ordest
is a null pointer -
destsz
orcount
is zero or greater than RSIZE_MAX / sizeof ( wchar_t ) -
there is no null wide character in the first
destsz
wide characters ofdest
-
truncation would occur:
count
or the length ofsrc
, whichever is less, exceeds the space available between the null terminator ofdest
anddestsz
. - overlap would occur between the source and the destination strings
-
-
As with all bounds-checked functions,
wcsncat_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> .
Parameters
dest | - | pointer to the null-terminated wide string to append to |
src | - | pointer to the null-terminated wide string to copy from |
count | - | maximum number of wide characters to copy |
destsz | - | the size of the destination buffer |
Return value
dest
dest
is a null pointer or
destsz
is zero or greater than
RSIZE_MAX
/
sizeof
(
wchar_t
)
).
Notes
Although truncation to fit the destination buffer is a security risk and therefore a runtime constraints violation for
wcsncat_s
, it is possible to get the truncating behavior by specifying
count
equal to the size of the destination array minus one: it will copy the first
count
wide characters and append the null terminator as always:
wcsncat_s
(
dst,
sizeof
dst
/
sizeof
*
dst, src,
(
sizeof
dst
/
sizeof
*
dst
)
-
wcsnlen_s
(
dst,
sizeof
dst
/
sizeof
*
dst
)
-
1
)
;
Example
Possible output:
Земля, прощай. В добрый
References
- C17 standard (ISO/IEC 9899:2018):
-
- 7.29.4.3.2 The wcsncat function (p: 315)
-
- K.3.9.2.2.2 The wcsncat_s function (p: 466-467)
- C11 standard (ISO/IEC 9899:2011):
-
- 7.29.4.3.2 The wcsncat function (p: 432-433)
-
- K.3.9.2.2.2 The wcsncat_s function (p: 643-644)
- C99 standard (ISO/IEC 9899:1999):
-
- 7.24.4.3.2 The wcsncat function (p: 378-379)
See also
(C95)
(C11)
|
appends a copy of one wide string to another
(function) |
(C11)
|
concatenates a certain amount of characters of two strings
(function) |
(C95)
(C11)
|
copies one wide string to another
(function) |
C++ documentation
for
wcsncat
|