Difference between revisions of "cpp/string/wide/wmemmove"
From cppreference.com
m (Update links.) |
(fix wording (these are for arrays of wide chars, not any objects)) |
||
Line 5: | Line 5: | ||
}} | }} | ||
− | Copies {{tt|count}} wide characters from the | + | Copies exactly {{tt|count}} successive wide characters from the wide character array pointed to by {{tt|src}} to the wide character array pointed to by {{tt|dest}}. |
+ | |||
+ | If {{tt|count}} is zero, the function does nothing. | ||
+ | |||
+ | The arrays may overlap: copying takes place as if the wide characters were copied to a temporary wide character array and then copied from the temporary array to {{tt|dest}}. | ||
===Parameters=== | ===Parameters=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | dest | pointer to the | + | {{par | dest | pointer to the wide character array to copy to}} |
− | {{par | src | pointer to the | + | {{par | src | pointer to the wide character array to copy from}} |
− | {{par | count | number of | + | {{par | count | number of wide characters to copy}} |
{{par end}} | {{par end}} | ||
===Return value=== | ===Return value=== | ||
− | {{tt|dest}} | + | Returns a copy of {{tt|dest}} |
+ | |||
+ | ===Notes=== | ||
+ | This function is not locale-sensitive and pays no attention to the values of the {{c|wchar_t}} objects it copies: nulls as well as invalid characters are copied too. | ||
===Example=== | ===Example=== | ||
Line 21: | Line 28: | ||
| | | | ||
| code= | | code= | ||
− | + | #include <iostream> | |
+ | #include <cwchar> | ||
+ | #include <locale> | ||
+ | #include <clocale> | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | std::setlocale(LC_ALL, "en_US.utf8"); | ||
+ | std::wcout.imbue(std::locale("en_US.utf8")); | ||
+ | |||
+ | wchar_t str[] = L"αβγδεζηθικλμνξοπρστυφχψω"; | ||
+ | std::wcout << str << '\n'; | ||
+ | std::wmemmove(str+4, str+3, 3); // copy from [δεζ] to [εζη] | ||
+ | std::wcout << str << '\n'; | ||
+ | } | ||
+ | |p=true | ||
+ | | output= | ||
+ | αβγδεζηθικλμνξοπρστυφχψω | ||
+ | αβγδδεζθικλμνξοπρστυφχψω | ||
}} | }} | ||
Line 27: | Line 52: | ||
{{dsc begin}} | {{dsc begin}} | ||
{{dsc inc | cpp/string/wide/dsc wmemcpy}} | {{dsc inc | cpp/string/wide/dsc wmemcpy}} | ||
+ | {{dsc inc | cpp/string/byte/dsc memmove}} | ||
{{dsc inc | cpp/algorithm/dsc copy}} | {{dsc inc | cpp/algorithm/dsc copy}} | ||
{{dsc inc | cpp/algorithm/dsc copy_backward}} | {{dsc inc | cpp/algorithm/dsc copy_backward}} | ||
− | |||
{{dsc see c | c/string/wide/wmemmove}} | {{dsc see c | c/string/wide/wmemmove}} | ||
{{dsc end}} | {{dsc end}} |
Revision as of 06:51, 26 February 2015
Defined in header <cwchar>
|
||
wchar_t* wmemmove( wchar_t* dest, const wchar_t* src, std::size_t count ); |
||
Copies exactly count
successive wide characters from the wide character array pointed to by src
to the wide character array pointed to by dest
.
If count
is zero, the function does nothing.
The arrays may overlap: copying takes place as if the wide characters were copied to a temporary wide character array and then copied from the temporary array to dest
.
Contents |
Parameters
dest | - | pointer to the wide character array to copy to |
src | - | pointer to the wide character array to copy from |
count | - | number of wide characters to copy |
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 copies: nulls as well as invalid characters are copied too.
Example
Run this code
#include <iostream> #include <cwchar> #include <locale> #include <clocale> int main() { std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); wchar_t str[] = L"αβγδεζηθικλμνξοπρστυφχψω"; std::wcout << str << '\n'; std::wmemmove(str+4, str+3, 3); // copy from [δεζ] to [εζη] std::wcout << str << '\n'; }
Possible output:
αβγδεζηθικλμνξοπρστυφχψω αβγδδεζθικλμνξοπρστυφχψω
See also
copies a certain amount of wide characters between two non-overlapping arrays (function) | |
moves one buffer to another (function) | |
(C++11) |
copies a range of elements to a new location (function template) |
copies a range of elements in backwards order (function template) | |
C documentation for wmemmove
|