wcschr ()- 搜尋寬字元

格式

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

語言層次

XPG4

安全執行緒

寬字元函數

如需相關資訊,請參閱 寬字元

說明

wcschr() 函數會搜尋寬字元 字串 ,以找出出現的 字元字元 可以是 wchar_t 空值字元 (\0); 搜尋中包括 string 結尾的 wchar_t 空值字元。

wcschr() 函數會對空值結束的 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'
*/

相關資訊