wcscspn
From cppreference.net
Null-terminated wide strings
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<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 "白猫 ".