wmemset() — Set wide character

Standards

Standards / Extensions C or C++ Dependencies
ISO C Amendment
C99
Single UNIX Specification, Version 3
both  

Format

Non-XPG4:
#include <wchar.h>

wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
XPG4:
#define _XOPEN_SOURCE
#define _MSE_PROTOS
#include <wchar.h>

wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);

General description

Copies the value of c into the first n wide chars of the object pointed to by s.

If n has the value 0, wmemset() copies zero wide characters.

Note: The function is now available as a built-in function under ARCH(7) when LP64 is not used.

Special behavior for XPG4: If you define any feature test macro specifying XPG4 behavior before the statement in your program source file to include the wchar header, then you must also define the _MSE_PROTOS feature test macro to make the declaration of the wmemset() function in the wchar header available when you compile your program. Please see Table 1 for a list of XPG4 and other feature test macros.

Returned value

wmemset() returns the value of s.

Example

#include <wchar.h>
#include <stdio.h>


  void main()
  {
   wchar_t  *in = L"1234ABCD";
   wchar_t  *ptr;

   printf("\nEXPECTED: AAAAAACD");
   ptr = wmemset(in, L'A', 6);
   if (ptr == in)
        printf("\nResults returned - %ls \n",ptr);
     else
       {
        printf("\n** ERROR ** wrong pointer returned\n");
       }

  }

Related information