strspn

来源:互联网 发布:海曙小学生编程 编辑:程序博客网 时间:2024/05/18 01:18


原型

size_t strspn(const char *s, const char * reject);


功能

若strcspn()返回的数值为n, 则代表字符串s 连续有n 个字符都包含reject 内的字符.


示例

#include <string.h>#include <iostream.h>void main(){    char *s="Golden Global View";    cout<<strspn(s, " ")<<endl;    cout<<strspn(s, "loG")<<endl;    cout<<strspn(s, "nedloG")<<endl;    cout<<strspn(s, "nGew")<<endl;}


结果:
0 //开始不包含空格
3 //有Gol
6 //有nedloG
1 //有G



0 0
原创粉丝点击