wmemset Function

Sets locations in an object to a specified value

Attention: This function is implemented only by MPLAB XC32 C compilers.

Include

<wchar.h>

Prototype

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

Arguments

s
the object to modify
c
the value to set
n
the number of locations to set

Return Value

A copy of s.

Remarks

The function sets the first n wide characters of the object pointed to by s to be the value c.

Example

#include <wchar.h>

int main(void)
{
  wchar_t ws1[20] = L"What time is it?";
  wchar_t ws2[20] = L"";
  wchar_t ch1 = L'?', ch2 = L'y';
  wchar_t * ptr;
  int res;

  printf("wmemset(\"%ls\", \'%lc\',4);\n", ws1, ch1);
  wmemset(ws1, ch1, 4);
  printf("ws1 after wmemset: %ls\n", ws1);

  printf("\n");
  printf("wmemset(\"%ls\", \'%lc\',10);\n", ws2, ch2);
  wmemset(ws2, ch2, 10);
  printf("ws2 after wmemset: %ls\n", ws2);
}

Example Output

wmemset("What time is it?", '?',4);
ws1 after wmemset: ???? time is it?

wmemset("", 'y',10);
ws2 after wmemset: yyyyyyyyyy