名前空間
変種
操作

std::wcscspn

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

destが指すワイド文字列の最大の前方部分文字列の長さを返します。この部分文字列は、srcが指すワイド文字列内に見つからない文字のみで構成されます。

目次

[編集] パラメータ

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

[編集] 戻り値

srcが指す文字文字列内に見つからない文字のみで構成される、最大の前方部分文字列の長さ。

[編集]

以下の出力は、clang (libc++) を使用して得られました。

#include <cwchar>
#include <iostream>
#include <locale>
 
int main()
{
    wchar_t dest[] = L"白猫 黑狗 甲虫";
    //                      └───┐
    const wchar_t* src = L"甲虫,黑狗";
 
    const std::size_t len = std::wcscspn(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 3.
The segment is "白猫 ".

[編集] 関連項目

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