wmemcpy() —Copy Wide-Character Buffer

Format

#include <wchar.h>
wchar_t *wmemcpy(wchar_t *s1, const wchar_t *s2, size_t n);

Language Level: ANSI

Threadsafe: Yes.

Wide Character Function: See Wide Characters for more information.

Description

The wmemcpy() function copies n wide characters from the object pointed to by s2 to the object pointed to by s1. If s1 and s2 overlap, the result of the copy is unpredictable. If n has the value 0, the wmemcpy() function copies 0 wide characters.

Return Value

The wmemcpy() function returns the value of s1.

Example that uses wmemcpy()

This example copies the first four characters from out to in. In the expected output, the first four characters in both strings will be "ABCD".

#include <wchar.h>
#include <stdio.h>
 
main()
{
   wchar_t *in = L"12345678";
   wchar_t *out = L"ABCDEFGH";
   wchar_t *ptr;
 
   printf("\nExpected result: First 4 chars of in change");
   printf(" and are the same as first 4 chars of out");
   ptr = wmemcpy(in, out, 4);
   if (ptr == in)
      printf("\nArray in %ls array out %ls \n", in, out);
   else
   {
   printf("\n*** ERROR ***");
   printf(" returned pointer wrong");
   }
}

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]