std::strspn
來自 cppreference.com
在標頭檔案 <cstring> 中定義 |
||
size_t strspn( const char* dest, const char* src ); |
||
返回指向 dest 的位元組字串的最大初始段(跨度)的長度,該初始段僅由指向 src 的位元組字串中找到的字元組成。
目錄 |
[編輯] 引數
dest | - | 指向要分析的以空字元結尾的位元組字串的指標 |
src | - | 指向包含要搜尋的字元的以空字元結尾的位元組字串的指標 |
[編輯] 返回值
僅包含指向 src 的位元組字串中字元的最大初始段的長度。
[編輯] 示例
執行此程式碼
#include <cstring> #include <iostream> #include <string> const char* low_alpha = "qwertyuiopasdfghjklzxcvbnm"; int main() { std::string s = "abcde312$#@"; std::size_t spnsz = std::strspn(s.c_str(), low_alpha); std::cout << "After skipping initial lowercase letters from '" << s << "'\nThe remainder is '" << s.substr(spnsz) << "'\n"; }
輸出
After skipping initial lowercase letters from 'abcde312$#@' The remainder is '312$#@'
[編輯] 參見
返回由另一個位元組字串中找到的字元組成的最大初始段的長度 僅由另一個位元組字串中未找到的字元組成 (函式) | |
返回由另一個位元組字串中找到的字元組成的最大初始段的長度 僅包含在另一個寬字串中找到的寬字元 (函式) | |
查詢分隔符集中任何字元的第一個位置 (函式) | |
C 文件 用於 strspn
|