summaryrefslogtreecommitdiff
path: root/devdocs/c/string%2Fwide%2Fwcsncat.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/string%2Fwide%2Fwcsncat.html
new repository
Diffstat (limited to 'devdocs/c/string%2Fwide%2Fwcsncat.html')
-rw-r--r--devdocs/c/string%2Fwide%2Fwcsncat.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/devdocs/c/string%2Fwide%2Fwcsncat.html b/devdocs/c/string%2Fwide%2Fwcsncat.html
new file mode 100644
index 00000000..17540682
--- /dev/null
+++ b/devdocs/c/string%2Fwide%2Fwcsncat.html
@@ -0,0 +1,67 @@
+ <h1 id="firstHeading" class="firstHeading">wcsncat, wcsncat_s</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;wchar.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl-rev-aux"> <td></td> <td rowspan="3">(1)</td> <td></td> </tr> <tr class="t-dcl t-since-c95 t-until-c99"> <td> <pre data-language="c">wchar_t *wcsncat( wchar_t *dest, const wchar_t *src, size_t count );</pre>
+</td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> <br><span class="t-mark-rev t-until-c99">(until C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">wchar_t *wcsncat( wchar_t *restrict dest,
+ const wchar_t *restrict src, size_t count );</pre>
+</td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">errno_t wcsncat_s( wchar_t *restrict dest, rsize_t destsz,
+ const wchar_t *restrict src, rsize_t count );</pre>
+</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <div class="t-li1">
+<span class="t-li">1)</span> Appends at most <code>count</code> wide characters from the wide string pointed to by <code>src</code>, stopping if the null terminator is copied, to the end of the character string pointed to by <code>dest</code>. The wide character <code>src[0]</code> replaces the null terminator at the end of <code>dest</code>. The null terminator is always appended in the end (so the maximum number of wide characters the function may write is <code>count+1</code>).</div> <div class="t-li1">
+ The behavior is undefined if the destination array is not large enough for the contents of both <code>str</code> and <code>dest</code> and the terminating null wide character.</div> <div class="t-li1">
+ The behavior is undefined if the strings overlap. </div> <div class="t-li1">
+<span class="t-li">2)</span> Same as <span class="t-v">(1)</span>, except that this function may clobber the remainder of the destination array (from the last wide character written to <code>destsz</code>) and that the following errors are detected at runtime and call the currently installed <a href="../../error/set_constraint_handler_s" title="c/error/set constraint handler s">constraint handler</a> function: <dl>
+<dd>
+<ul>
+<li> <code>src</code> or <code>dest</code> is a null pointer </li>
+<li> <code>destsz</code> or <code>count</code> is zero or greater than <code>RSIZE_MAX/sizeof(wchar_t)</code> </li>
+<li> there is no null wide character in the first <code>destsz</code> wide characters of <code>dest</code> </li>
+<li> truncation would occur: <code>count</code> or the length of <code>src</code>, whichever is less, exceeds the space available between the null terminator of <code>dest</code> and <code>destsz</code>. </li>
+<li> overlap would occur between the source and the destination strings </li>
+</ul> </dd>
+<dd>As with all bounds-checked functions, <code>wcsncat_s</code> only guaranteed to be available if <code>__STDC_LIB_EXT1__</code> is defined by the implementation and if the user defines <code>__STDC_WANT_LIB_EXT1__</code> to the integer constant <code>1</code> before including <a href="../wide" title="c/string/wide"><code>&lt;wchar.h&gt;</code></a>.</dd>
+</dl>
+</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> dest </td> <td> - </td> <td> pointer to the null-terminated wide string to append to </td>
+</tr> <tr class="t-par"> <td> src </td> <td> - </td> <td> pointer to the null-terminated wide string to copy from </td>
+</tr> <tr class="t-par"> <td> count </td> <td> - </td> <td> maximum number of wide characters to copy </td>
+</tr> <tr class="t-par"> <td> destsz </td> <td> - </td> <td> the size of the destination buffer </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <div class="t-li1">
+<span class="t-li">1)</span> returns a copy of <code>dest</code>
+</div> <div class="t-li1">
+<span class="t-li">2)</span> returns zero on success, returns non-zero on error. Also, on error, writes <code>L'\0'</code> to <code>dest[0]</code> (unless <code>dest</code> is a null pointer or <code>destsz</code> is zero or greater than <code>RSIZE_MAX/sizeof(wchar_t)</code>).</div> <h3 id="Notes"> Notes</h3> <p>Although truncation to fit the destination buffer is a security risk and therefore a runtime constraints violation for <code>wcsncat_s</code>, it is possible to get the truncating behavior by specifying <code>count</code> equal to the size of the destination array minus one: it will copy the first <code>count</code> wide characters and append the null terminator as always: <code>wcsncat_s(dst, sizeof dst/sizeof *dst, src, (sizeof dst/sizeof *dst)-wcsnlen_s(dst, sizeof dst/sizeof *dst)-1);</code></p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;wchar.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;locale.h&gt;
+
+int main(void)
+{
+ wchar_t str[50] = L"Земля, прощай.";
+ wcsncat(str, L" ", 1);
+ wcsncat(str, L"В добрый путь.", 8); // only append the first 8 wide chars
+ setlocale(LC_ALL, "en_US.utf8");
+ printf("%ls", str);
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">Земля, прощай. В добрый</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul>
+<li> 7.29.4.3.2 The wcsncat function (p: 315) </li>
+<li> K.3.9.2.2.2 The wcsncat_s function (p: 466-467) </li>
+</ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.29.4.3.2 The wcsncat function (p: 432-433) </li>
+<li> K.3.9.2.2.2 The wcsncat_s function (p: 643-644) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.24.4.3.2 The wcsncat function (p: 378-379) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="wcscat" title="c/string/wide/wcscat"> <span class="t-lines"><span>wcscat</span><span>wcscat_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> appends a copy of one wide string to another <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="../byte/strncat" title="c/string/byte/strncat"> <span class="t-lines"><span>strncat</span><span>strncat_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> concatenates a certain amount of characters of two strings <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="wcscpy" title="c/string/wide/wcscpy"> <span class="t-lines"><span>wcscpy</span><span>wcscpy_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> copies one wide string to another <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/string/wide/wcsncat" title="cpp/string/wide/wcsncat">C++ documentation</a></span> for <code>wcsncat</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/string/wide/wcsncat" class="_attribution-link">https://en.cppreference.com/w/c/string/wide/wcsncat</a>
+ </p>
+</div>