Difference between revisions of "cpp/string/wide/wcsncat"
From cppreference.com
(example link to byte, upd wording) |
Andreas Krug (Talk | contribs) m ({{c}}, fmt, str -> src, langlinks) |
||
Line 1: | Line 1: | ||
{{cpp/title| wcsncat}} | {{cpp/title| wcsncat}} | ||
{{cpp/string/wide/navbar}} | {{cpp/string/wide/navbar}} | ||
− | {{ddcl | header=cwchar | | + | {{ddcl|header=cwchar| |
wchar_t *wcsncat( wchar_t *dest, const wchar_t *src, std::size_t count ); | wchar_t *wcsncat( wchar_t *dest, const wchar_t *src, std::size_t count ); | ||
}} | }} | ||
− | Appends at most {{ | + | Appends at most {{c|count}} wide characters from the wide string pointed to by {{c|src}} to the end of the character string pointed to by {{c|dest}}, stopping if the null terminator is copied. The wide character {{c|src[0]}} replaces the null terminator at the end of {{c|dest}}. The null terminator is always appended in the end (so the maximum number of wide characters the function may write is {{c|count + 1}}). |
− | The behavior is undefined if the destination array is not large enough for the contents of both {{ | + | The behavior is undefined if the destination array is not large enough for the contents of both {{c|src}} and {{c|dest}} and the terminating null wide character. |
The behavior is undefined if the strings overlap. | The behavior is undefined if the strings overlap. | ||
Line 13: | Line 13: | ||
===Parameters=== | ===Parameters=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | dest | pointer to the null-terminated wide string to append to}} | + | {{par|dest|pointer to the null-terminated wide string to append to}} |
− | {{par | src | pointer to the null-terminated wide string to copy from}} | + | {{par|src|pointer to the null-terminated wide string to copy from}} |
− | {{par | count | maximum number of wide characters to copy}} | + | {{par|count|maximum number of wide characters to copy}} |
{{par end}} | {{par end}} | ||
===Return value=== | ===Return value=== | ||
− | {{ | + | {{c|dest}} |
===Example=== | ===Example=== | ||
{{example | {{example | ||
− | + | |code= | |
− | + | #include <clocale> | |
#include <cwchar> | #include <cwchar> | ||
#include <iostream> | #include <iostream> | ||
− | |||
int main(void) | int main(void) | ||
Line 46: | Line 45: | ||
===See also=== | ===See also=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/string/wide/dsc wcscat}} | + | {{dsc inc|cpp/string/wide/dsc wcscat}} |
− | {{dsc inc | cpp/string/byte/dsc strncat}} | + | {{dsc inc|cpp/string/byte/dsc strncat}} |
− | {{dsc inc | cpp/string/wide/dsc wcscpy}} | + | {{dsc inc|cpp/string/wide/dsc wcscpy}} |
− | {{dsc see c | c/string/wide/wcsncat}} | + | {{dsc see c|c/string/wide/wcsncat}} |
{{dsc end}} | {{dsc end}} | ||
− | + | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 07:37, 10 June 2023
Defined in header <cwchar>
|
||
wchar_t *wcsncat( wchar_t *dest, const wchar_t *src, std::size_t count ); |
||
Appends at most count wide characters from the wide string pointed to by src to the end of the character string pointed to by dest, stopping if the null terminator is copied. 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).
The behavior is undefined if the destination array is not large enough for the contents of both src and dest and the terminating null wide character.
The behavior is undefined if the strings overlap.
Contents |
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 |
Return value
dest
Example
Run this code
#include <clocale> #include <cwchar> #include <iostream> int main(void) { wchar_t str[50] = L"Земля, прощай."; std::wcsncat(str, L" ", 1); std::wcsncat(str, L"В добрый путь.", 8); // only append the first 8 wide chars std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << str << '\n'; }
Possible output:
Земля, прощай. В добрый
See also
appends a copy of one wide string to another (function) | |
concatenates a certain amount of characters of two strings (function) | |
copies one wide string to another (function) | |
C documentation for wcsncat
|