#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
int i;
char str[] = "129th";
char accept[] = "1234567890";
i = strspn(str, accept);
printf("str 前 %d 个字符都属于 accept\n",i);
system("pause");
return 0;
}
str 前 3 个字符都属于 accept
int strcspn(char *str, char *accept);
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
char* s1 = "http://c.biancheng.net/cpp/u/biaozhunku/";
char* s2 = "c is good";
int n = strcspn(s1,s2);
printf("The first char both in s1 and s2 is :%c\n",s1[n]);
printf("The position in s1 is: %d\n",n);
system("pause");
return 0;
}
The first char both in s1 and s2 is :c The position in s1 is: 7
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
char* s1 = "http://c.biancheng.net/cpp/xitong/";
char* s2 = "z -+*";
if(strlen(s1) == strcspn(s1,s2)){
printf("s1 is diffrent from s2!\n");
}else{
printf("There is at least one same character in s1 and s2!\n");
}
system("pause");
return 0;
}
s1 is diffrent from s2!
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有