名前空間
変種
操作

wcscspn

From cppreference.com
< c‎ | string‎ | wide
 
 
 
 
ヘッダー <wchar.h> で定義
size_t wcscspn( const wchar_t* dest, const wchar_t* src );
(C95 以降)

dest が指すワイド文字列の、src が指すワイド文字列に含まれる文字 *以外* の文字のみからなる最大の前方部分文字列の長さを返します。

目次

[編集] パラメータ

dest - 解析対象のヌル終端ワイド文字列へのポインタ
src - 検索対象の文字を含むヌル終端ワイド文字列へのポインタ

[編集] 戻り値

src が指す文字文字列に含まれていない文字のみを含む、最大の前方部分文字列の長さ。

[編集]

#include <locale.h>
#include <wchar.h>
 
int main(void)
{
    wchar_t dest[] = L"白猫 黑狗 甲虫";
    /*                      └───┐   */
    const wchar_t *src = L"甲虫,黑狗";
 
    const size_t len = wcscspn(dest, src);
    dest[len] = L'\0'; /* terminates the segment to print it out */
 
    setlocale(LC_ALL, "en_US.utf8");
    wprintf(L"The length of maximum initial segment is %td.\n"
            L"The segment is \"%ls\".\n", len, dest);
}

出力

The length of maximum initial segment is 3.
The segment is "白猫 ".

[編集] 参考文献

  • C11標準 (ISO/IEC 9899:2011)
  • 7.29.4.5.2 wcscspn 関数 (p: 435-436)
  • C99標準 (ISO/IEC 9899:1999)
  • 7.24.4.5.2 wcscspn 関数 (p: 381-382)

[編集] 関連項目

(C95)
以下から成る最大の初期セグメントの長さを返す
別のワイド文字列に含まれるワイド文字のみからなる
(関数) [編集]
あるワイド文字列に含まれるいずれかのワイド文字が、別のワイド文字列内で最初に現れる場所を見つける
(関数) [編集]
English 日本語 中文(简体) 中文(繁體)