2.1 strpbrk
原型:char *strpbrk(const char *s, const char *accept);
描述:strpbrk()函数在字符串s中查找字符串accept中的任一字符第一次出的位置返回值:返回指向s中一个字符的指针,
该字符是第一个与accept中一个字符匹配的字符。如果没有匹配的字符,则返回NULL。
在字符串前缀中查找未出现的字符个数
在字符串前缀中查找出现的字符个数
切割字符串,将字符串分为一个一个子串
函数的使用
int main()
{
char s1[] = "i like china";
char s2[] = "ch";
char *result = strpbrk(s1, s2);
printf("%c\n", *result);
int tmp1= strcspn(s1, s2);
printf("%d\n", tmp1);
int tmp2= strspn(s1, s2);
printf("%d\n", tmp2);
char buf[] = "hello@boy@this@is@heima";
char*temp = strtok(buf, "@");
while (temp)
{
printf("%s ", temp);
temp = strtok(NULL, "@");
}
system("pause:");
return 0;
}