How to set a wide character buffer to a value in C

1 Answer

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

// wchar_t* wmemset (wchar_t* ptr, wchar_t wc, size_t num);
// Fill array of wide characters

// Sets the first num elements of the array of wide characters pointed by ptr 
// to the value specified as wc
 
void main()
{
    wchar_t arr[] = L"12345ABCDE";
    wchar_t *ptr;
 
    wchar_t *p = wmemset(arr, L'*', 5);
    
    if (p == arr) {
        printf("%ls\n", p);
    }
    else {
        printf("ERROR\n");
    }
}



/*
run:

*****ABCDE

*/

 



answered Aug 7, 2024 by avibootz
...