wmemcpy
appears to perform the same operations as memcpy
but accepts wchar_t*
instead of void*
. How is its existence just
In addition to davmac's answer about API symmetry and having the size of an array not always granted, it should be emphasized that the third argument of wmemcpy
refers to number of elements to copy (rather than bytes).
If you work with wchar_t
objects and handle them with other functions from
, it may facilitate matters. wcslen
for instance returns the C wide string length in terms of wchar_t
elements, and wcschr
and wcsrchr
return wchar_t *
, thus using them to do some pointer arithmetic also keeps you in the "realm" of number-of-elements.
P.S. If the size of the minimal wchar_t
array is given as implied in your example, using wmemcpy
may result in more elegant code than that sizeof(wchar_array)
you used:
#define SIZE 40
wchar_t wchar_array[SIZE];
// ...
wmemcpy(dest, wchar_array, SIZE);