C Standard Libraries C++

wmemset()

Declaration

wchar_t* wmemset(wchar_t* wpDest,
                 wchar_t wChar,
                 size_t uiCount);

Description

This function copies "uiCount" wide-characters equal "wChar" to the buffer "wpDest" and returns a pointer to "wpDest."

Example

#include <cwchar>

int main()
{
    wchar_t waBuffer[] = L"XoaX.net";
    wchar_t wX = L'X';
    size_t uiCopySize = 5;

    wprintf(L"%u \"%wc\" characters were copied to \"%ws\"\n",
        uiCopySize, wX, waBuffer);
    // Copy 5 Xs to the buffer
    wmemset(waBuffer, wX, uiCopySize);
    wprintf(L"The Result is = \"%ws\"\n", waBuffer);

    // Keep the window open until "Enter" is pressed
    getwchar();
    return 0;
}

Output

wmemset() Output
 

© 2007–2022 XoaX.net LLC. All rights reserved.