wcsspn
From cppreference.net
Null-terminated wide strings
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<wchar.h>
|
||
|
size_t
wcsspn
(
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 = wcsspn(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 6. The segment is "白猫 黑狗 ".