名前空間
変種
操作

std::wcsspn

From cppreference.com
< cpp‎ | string‎ | wide
 
 
 
 
ヘッダ <cwchar> で定義
size_t wcsspn( const wchar_t* dest, const wchar_t* src );

dest を指すワイド文字列の、src を指すワイド文字列に含まれる文字のみで構成される最大先行部分文字列の長さを返します。

目次

[編集] パラメーター

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

[編集] 戻り値

src を指すワイド文字列からの文字のみを含む最大先行部分文字列の長さ。

[編集]

#include <cwchar>
#include <iostream>
#include <locale>
 
int main()
{
    wchar_t dest[] = L"白猫 黑狗 甲虫";
    const wchar_t src[] = L" 狗猫 白黑 ";
    const std::size_t len = std::wcsspn(dest, src);
    dest[len] = L'\0'; // terminates the segment to print it out
 
    std::wcout.imbue(std::locale("en_US.utf8"));
    std::wcout << L"The length of maximum initial segment is " << len << L".\n";
    std::wcout << L"The segment is \"" << dest << L"\".\n";
}

実行結果の例

The length of maximum initial segment is 6.
The segment is "白猫 黑狗 ".

[編集] 関連項目

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