From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/string%2Fwide%2Fwmemset.html | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 devdocs/c/string%2Fwide%2Fwmemset.html (limited to 'devdocs/c/string%2Fwide%2Fwmemset.html') diff --git a/devdocs/c/string%2Fwide%2Fwmemset.html b/devdocs/c/string%2Fwide%2Fwmemset.html new file mode 100644 index 00000000..76e41a84 --- /dev/null +++ b/devdocs/c/string%2Fwide%2Fwmemset.html @@ -0,0 +1,45 @@ +

wmemset

Defined in header <wchar.h>
wchar_t* wmemset( wchar_t* dest, wchar_t ch, size_t count );
+
(since C95)

Copies the wide character ch into each of the first count wide characters of the wide character array (or integer array of compatible type) pointed to by dest.

+

If overflow occurs, the behavior is undefined.

+

If count is zero, the function does nothing.

+

Parameters

+ + + +
dest - pointer to the wide character array to fill
ch - fill wide character
count - number of wide characters to fill

Return value

Returns a copy of dest

+

Notes

This function is not locale-sensitive and pays no attention to the values of the wchar_t objects it writes: nulls as well as invalid wide characters are written too.

+

Example

#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+ 
+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 < sizeof ar / sizeof *ar; ++n)
+        putwchar(ar[n]);
+    putwchar(L'\n');
+}

Output:

+
🍌🍌🍌🍌🍌蕉蕉蕉蕉蕉

References

See also

+ + +
+
(C23)(C11)
fills a buffer with a character
(function)
+
(C95)(C11)
copies a certain amount of wide characters between two non-overlapping arrays
(function)
C++ documentation for wmemset
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/string/wide/wmemset +

+
-- cgit v1.2.3