C examples for wchar.h:wcschr
function
<cwchar> <wchar.h>
Locate first occurrence of character in wide string
const wchar_t* wcschr (const wchar_t* ws, wchar_t wc); wchar_t* wcschr ( wchar_t* ws, wchar_t wc);
Parameter | Description |
---|---|
ws | C wide string. |
wc | 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.
#include <wchar.h> int main ()/*from ww w . j av a 2 s . com*/ { wchar_t wcs[] = L"This is a sample wide string"; wchar_t * pwc; wprintf (L"Looking for the 's' character in \"%ls\"...\n",wcs); pwc=wcschr(wcs,L's'); while (pwc!=NULL) { wprintf (L"found at %d\n",pwc-wcs+1); pwc=wcschr(pwc+1,L's'); } return 0; }