wcscspn ()- 尋找第一個寬字元比對的偏移
格式
#include <wchar.h>
size_t wcscspn(const wchar_t *string1, const wchar_t *string2);語言層次
XPG4
安全執行緒
是
寬字元函數
如需相關資訊,請參閱 寬字元 。
說明
wcscspn() 函數決定 string1 所指向之字串的起始區段中,未出現在 string2所指向之字串中的 wchar_t 字元數。
wcscspn() 函數會處理以空值結尾的 wchar_t 字串; 此函數的字串引數應該包含 wchar_t 空值字元標示字串結尾。
回覆值
wcscspn() 函數會傳回區段中 wchar_t 個字元的數目。
範例
此範例使用
wcscspn() 來尋找 字串中任何字元 a、 x、 l或 e 的第一次出現。#include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t string[SIZE] = L"This is the source string";
wchar_t * substring = L"axle";
printf( "The first %i characters in the string \"%ls\" are not in the "
"string \"%ls\" \n", wcscspn( string, substring),
string, substring );
}
/**************** Output should be similar to: ******************
The first 10 characters in the string "This is the source string" are not
in the string "axle"
*/