Bug in wmemcpy documentation

Content from http://www.cplusplus.com/reference/cwchar/wmemcpy/ :

Parameters

destination
Pointer to the destination array where the content is to be copied.
source
Pointer to the source of data to be copied.
num
Number of bytes to copy.
size_t is an unsigned integral type.


num actually is number of byte pair (one wchar_t)!
Copy block of wide characters
Copies the values of num elements of type wchar_t from the location pointed by source to the location pointed by destination.


wmemcpy declaration from wchar.h:
1
2
3
4
5
6
7
__inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemcpy_s) wchar_t * __CRTDECL wmemcpy(_Out_opt_cap_(_N) wchar_t *_S1, _In_opt_count_(_N) const wchar_t *_S2, _In_ size_t _N)
        {
#pragma warning( push )
#pragma warning( disable : 4996 6386 )
            return (wchar_t *)memcpy(_S1, _S2, _N*sizeof(wchar_t));
#pragma warning( pop )
        }
Last edited on
Yes, rather than saying "Number of bytes to copy", it should rather say "Number of elements to copy" (or the like). Rather than posting here, though, go down to the bottom of the page and click the "Spotted an error? contact us" hyperlink.
Topic archived. No new replies allowed.