summaryrefslogtreecommitdiff
path: root/devdocs/c/string%2Fwide%2Fwmemset.html
blob: 76e41a84c0ad65237b201172ec390f5433cd8bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    <h1 id="firstHeading" class="firstHeading">wmemset</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"> <td> <pre data-language="c">wchar_t* wmemset( wchar_t* dest, wchar_t ch, size_t count );</pre>
</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> </td> </tr>  </table> <p>Copies the wide character <code>ch</code> into each of the first <code>count</code> wide characters of the wide character array (or integer array of compatible type) pointed to by <code>dest</code>.</p>
<p>If overflow occurs, the behavior is undefined.</p>
<p>If <code>count</code> is zero, the function does nothing.</p>
<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> dest </td> <td> - </td> <td> pointer to the wide character array to fill </td>
</tr> <tr class="t-par"> <td> ch </td> <td> - </td> <td> fill wide character </td>
</tr> <tr class="t-par"> <td> count </td> <td> - </td> <td> number of wide characters to fill </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>Returns a copy of <code>dest</code></p>
<h3 id="Notes"> Notes</h3> <p>This function is not locale-sensitive and pays no attention to the values of the <code>wchar_t</code> objects it writes: nulls as well as invalid wide characters are written too.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;locale.h&gt;
#include &lt;stdio.h&gt;
#include &lt;wchar.h&gt;
 
int main(void)
{
    wchar_t ar[10] = L"1234567890"; // no trailing null in the array
    wmemset(ar, L'\U0001f34c', 5); // replaces [12345] with the 🍌 bananas
    wmemset(ar + 5, L'蕉', 5); // replaces [67890] with the 蕉 bananas
 
    setlocale(LC_ALL, "en_US.utf8");
    for (size_t n = 0; n &lt; sizeof ar / sizeof *ar; ++n)
        putwchar(ar[n]);
    putwchar(L'\n');
}</pre></div> <p>Output:</p>
<div class="text source-text"><pre data-language="c">🍌🍌🍌🍌🍌蕉蕉蕉蕉蕉</pre></div> </div> <h3 id="References"> References</h3>  <ul>
<li> C23 standard (ISO/IEC 9899:2023): </li>
<ul><li> 7.29.4.6.2 The wmemset function (p: TBD) </li></ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul><li> 7.29.4.6.2 The wmemset function (p: TBD) </li></ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul><li> 7.29.4.6.2 The wmemset function (p: 439) </li></ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul><li> 7.24.4.6.2 The wmemset function (p: 385) </li></ul>
</ul>               <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="../byte/memset" title="c/string/byte/memset"> <span class="t-lines"><span>memset</span><span>memset_explicit</span><span>memset_s</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> fills a buffer with a character <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="wmemcpy" title="c/string/wide/wmemcpy"> <span class="t-lines"><span>wmemcpy</span><span>wmemcpy_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 a certain amount of wide characters between two non-overlapping arrays <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/wmemset" title="cpp/string/wide/wmemset">C++ documentation</a></span> for <code>wmemset</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/wmemset" class="_attribution-link">https://en.cppreference.com/w/c/string/wide/wmemset</a>
  </p>
</div>