const wchar_t* wcsrchr (const wchar_t* ws, wchar_t wc);
wchar_t* wcsrchr ( wchar_t* ws, wchar_t wc);
Locate last occurrence of character in wide string
Returns a pointer to the last occurrence of wc in the C wide string ws.
The terminating null wide character is considered part of the string. Therefore, it can also be located 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 last 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 * wcsrchr ( const wchar_t *, wchar_t );
instead of the two overloaded versions provided in C++.
/* wcsrchr example */
int main ()
wchar_t wcs = L"This is a sample wide string";
wchar_t * pwc;
pwc = wcsrchr (wcs,L's');
wprintf (L"Last occurence of L's' found at %d \n",pwc-wcs+1);
Last occurrence of L's' found at 23
- Locate last occurrence of character in string (function
- Locate first occurrence of character in wide string (function
- Locate character in block of wide characters (function
- Locate characters in wide string (function