C Standard Libraries C++

wmemchr()

Declaration

const wchar_t* wmemchr(const wchar_t* kwpBuffer,
                       wchar_t wChar,
                       size_t uiCount);

Description

This function searches the first "uiCount" wide-characters of the string "kwpBuffer" for first occurrence of "wChar" and returns a pointer to it. If the character could not be found, the function returns NULL.

Example

#include <cwchar>

int main()
{
    wchar_t waString[] = L"XoaX.net";
    size_t uiSearchSize = 5;
    wchar_t wChar = L'a';

    wprintf(L"Searching %d entries of \"%ws\" for an \"%wc\"\n",
            uiSearchSize, waString, wChar);
    // Search 5 entries in the buffer for character
    wchar_t* wpFound = wmemchr(waString, 'a', uiSearchSize);
    wprintf(L"Found an \"%wc\" at \"%ws\"\n",
            wChar, wpFound);

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

Output

wmemchr() Output
 

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