wcsspn() - ストリング内のワイド文字の検索

標準

標準/拡張機能 C/C++ 依存項目

ISO C 改訂
XPG4
XPG4.2
C99
Single UNIX Specification、バージョン 3

両方  

形式

#include <wchar.h>

size_t wcsspn(const wchar_t *string1, const wchar_t *string2);

機能説明

string1 が指すストリングの初期セグメントに あって、すべて string2 が指すストリングの ワイド文字から成るワイド文字数を計算します。

このワイド文字関数の動作は、現行ロケールの LC_CTYPE カテゴリーの影響を受けます。 カテゴリーを変更すると、未定義の結果が発生する可能性があります。

戻り値

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

CELEBW19
⁄* CELEBW19                                      

   This example finds the first occurrence in the array string                  
   of a character that is neither an a, b, nor c. Because the                   
   string in this example is cabbage, &wcsspn. returns 5, the                   
   index of the segment of cabbage before a character that is                   
   not an a, b, or c.                                                           
                                                                                
 *⁄                                                                             
#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 );                                          
}                                                                               
出力:
The first 5 characters of "cabbage" are found in "abc"

関連情報