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