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() を使用して、string で
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"
*/