C Standard Libraries C++

wcschr()

Declaration

wchar_t* wcschr(const wchar_t* kwpWideString, wchar_t wWideChar);

Description

This function locates the first instance of the wide-character "wWideChar" in side of the string "kwpWideString" and returns a pointer to it. If the character cannot be found inside the string, the function returns NULL.

Example

#include <cwchar>

int main()
{
    wchar_t waWideString[] = L"XoaX.net";

    wchar_t wSearched = L'.';
    wprintf(L"Searching \"%ws\" for \"%wc\"\n",
        waWideString, wSearched);
    // Search the string for a period
    wchar_t* wpFound = wcschr(waWideString, wSearched);
    int iFoundIndex = (int)(wpFound - waWideString);
    wprintf(L"The first \"%wc\" was found at the index %d.\n",
        wSearched, iFoundIndex);

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

Output

wcschr() Output
 

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