wcschr() — Search for Wide Character
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
This example finds the first occurrence
of the character
pin 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
- strchr() — Search for Character
- strcspn() — Find Offset of First Character Match
- strpbrk() — Find Characters in String
- strrchr() — Locate Last Occurrence of Character in String
- strspn() — Find Offset of First Non-matching Character
- wcscat() — Concatenate Wide-Character Strings
- wcscmp() — Compare Wide-Character Strings
- wcscpy() — Copy Wide-Character Strings
- wcscspn() — Find Offset of First Wide-Character Match
- wcslen() — Calculate Length of Wide-Character String
- wcsncmp() — Compare Wide-Character Strings
- wcspbrk() — Locate Wide Characters in String
- wcsrchr() — Locate Last Occurrence of Wide Character in String
- wcsspn() — Find Offset of First Non-matching Wide Character
- wcswcs() — Locate Wide-Character Substring
- <wchar.h>