c和指针(笔记)
1、char *strpbrk(char const *str, char const *group) 在str中查找和group第一个匹配字符的位置,没有的话返回NULL。
例如:
char str[] = "I don't want to eat rice.";
char *group = "rice";
char *result;
result = strpbrk(str, group);//result 指向出现group中第一次出现的字符的位置,这里result指向r,即result = “eat rice”。
2、size_t strspn(char const *str, char const * group);在str开头中查找和group出现的任意字符匹配的最长字符数
例如:
char str[] = "I don't want to eat rice.";
char *group = "rice";
int max = 0;
max = strspn(str, group);//max = 0.
3、size_t strcspn(char const *str, char const* group);和上面正好相反,是对不匹配的数进行计数。
例如:
char str[] = "I don't want to eat rice.";
char *group = "rice";
int max = 0;
max = strcspn(str, group);//max = 16.