std::wcscspn
來自 cppreference.com
在標頭檔案 <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 "白貓 ".
[編輯] 參閱
返回由另一個位元組字串中找到的字元組成的最大初始段的長度 僅包含在另一個寬字串中找到的寬字元 (函式) | |
在另一個寬字串中查詢一個寬字串中任意寬字元的首次出現位置 (函式) | |
C 文件 為 wcscspn
|