wcschr() — Search for wide-character substring
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
Format
#include <wchar.h>
wchar_t *wcschr(const wchar_t *string1, wchar_t character);
General description
Searches string for the occurrence of character. The character may be a wide NULL character (\0). The wide NULL character at the end of string is included in the search. The wcschr() function operates on NULL-terminated wide-character strings. The argument to this function must contain a wide NULL character marking the end of the string.
The behavior of this wide-character function is affected by the LC_CTYPE category of the current locale. If you change the category, undefined results can occur.
Returned value
If successful, wcschr() returns a pointer to the first occurrence of character in string.
If the character is not found, wcschr() returns a NULL pointer.
Example
CELEBW05
/* CELEBW05
This example finds the first occurrence of the character p in
the wide character string "computer program" using &wcschr..
*/
#include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t buffer1[SIZE] = L"computer program";
wchar_t * ptr;
wint_t ch = L'p';
ptr = wcschr( buffer1, ch );
printf( "The first occurrence of %lc in '%ls' is '%ls'\n",
ch, buffer1, ptr );
}
Output:
The first occurrence of p in 'computer program' is 'puter program'
Related information
- wchar.h
- wcstr.h
- strchr() — Search for character
- wcscat() — Append to wide-character string
- wcscmp() — Compare wide-character strings
- wcscpy() — Copy wide-character string
- wcscspn() — Find offset of first wide-character match
- wcslen() — Calculate length of wide-character string
- wcsncmp() — Compare wide-character strings