wcschr ()- 搜索宽字符

格式

#include <wchar.h>
wchar_t *wcschr(const wchar_t *string, wchar_t character);

语言级别

XPG4

线程安全

宽字符函数

有关更多信息,请参阅 宽字符

描述

wcschr() 函数在宽字符 字符串 中搜索出现的 字符字符 可以是 wchar_t 空字符 (\0); string 末尾的 wchar_t 空字符包含在搜索中。

wcschr() 函数对以 null 结束的 wchar_t 字符串执行操作。 此函数的字符串自变量应包含标记字符串结束的 wchar_t 空字符。

返回值

wcschr() 函数返回一个指针,该指针指向 string中首次出现的 字符 。 如果找不到该字符,那么将返回 NULL 指针。

示例

此示例在宽字符字符串 computer program中首次出现字符 p
#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'
*/

相关信息