const wchar_t* wcschr (const wchar_t* ws, wchar_t wc);
wchar_t* wcschr ( wchar_t* ws, wchar_t wc);
Locate first occurrence of character in wide string
Returns a pointer to the first occurrence of the wide character wc in the C wide string ws.
The terminating null wide character is considered part of the string. Therefore, it can also be located in order to retrieve a pointer to the end of a wide string.
This is the wide character equivalent of strchr (<cstring>).
- C wide string.
- Wide character to be located.
A pointer to the first occurrence of wc in ws.
If wc is not found, the function returns a null pointer.
In C, this function is only declared as:
wchar_t * strchr ( const wchar_t *, wchar_t );
instead of the two overloaded versions provided in C++.
/* wcschr example */
int main ()
wchar_t wcs = L"This is a sample wide string";
wchar_t * pwc;
wprintf (L"Looking for the 's' character in \"%ls\"...\n",wcs);
wprintf (L"found at %d\n",pwc-wcs+1);
Looking for the 's' character in "This is a sample string"...
found at 4
found at 7
found at 11
found at 23
- Locate first occurrence of character in string (function
- Locate last occurrence of character in wide string (function
- Locate character in block of wide characters (function
- Locate characters in wide string (function