wcsspn() — 最初の一致しないワイド文字のオフセットを検索します

形式

#include <wchar.h>
size_t wcsspn(const wchar_t *string1, const wchar_t *string2);

言語レベル

ANSI

スレッド・セーフ

はい

ワイド文字関数

詳しくは、 ワイド文字 を参照してください。

説明

wcsspn() 関数は、 string1が指すストリングの初期セグメント内のワイド文字数を計算します。これは、 string2が指すストリングからのワイド文字全体で構成されます。

戻り値

wcsspn() 関数は、セグメント内のワイド文字の数を戻します。

この例は、配列 string で、ab、または c 以外の ワイド文字が最初に現れる位置を検索します。 この例のストリングは cabbageであるため、 wcsspn() 関数は、 ab、または c以外の文字の前の cabbage のセグメントの索引である 5を返します。
#include <stdio.h>
#include <wchar.h>
 
int main(void)
{
  wchar_t * string = L"cabbage";
  wchar_t * source = L"abc";
  int index;
 
  index = wcsspn( string, L"abc" );
  printf( "The first %d characters of \"%ls\" are found in \"%ls\"\n",
              index, string, source );
}
 
/****************  Output should be similar to:  ******************
 
The first 5 characters of "cabbage" are found in "abc"
*/

関連情報