Format
#include <wchar.h>
wchar_t *wcschr(const wchar_t *string, wchar_t character);
Language Level: XPG4
Threadsafe: Yes.
Wide Character Function: See Wide Characters for more information.
Description
The wcschr() function searches the wide-character string for the occurrence of character. The character can be a wchar_t null character (\0); the wchar_t null character at the end of string is included in the search.
The wcschr() function operates on null-ended wchar_t strings. The string argument to this function should contain a wchar_t null character marking the end of the string.
Return Value
The wcschr() function returns a pointer to the first occurrence of character in string. If the character is not found, a NULL pointer is returned.
Example that uses wcschr()
This example finds the first occurrence of the character "p" in the wide-character string "computer program".
#include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t buffer1[SIZE] = L"computer program";
wchar_t * ptr;
wchar_t ch = L'p';
ptr = wcschr( buffer1, ch );
printf( "The first occurrence of %lc in '%ls' is '%ls'\n",
ch, buffer1, ptr );
}
/**************** Output should be similar to: ******************
The first occurrence of p in 'computer program' is 'puter program'
*/
Related Information