strcspn函数
来源:互联网 发布:pdf 密码移除 mac 编辑:程序博客网 时间:2024/05/17 16:44
ohn,he like writing!";
int inttemp;
inttemp=strcspn(str1,str2); //将str2中的每个字符均与str1中的匹配,如果这个字符在str1中出现过,则返回这个字符在str1中的索引值
printf("The first index of the character both in str1 and str2: %d ", inttemp);
return 0;
}
int inttemp;
inttemp=strcspn(str1,str2); //将str2中的每个字符均与str1中的匹配,如果这个字符在str1中出现过,则返回这个字符在str1中的索引值
printf("The first index of the character both in str1 and str2: %d ", inttemp);
return 0;
}
在VC++ 6.0编译运行:
匹配过程是这样的:
str2中第一个字符“J”先与str1中的每个字符比较,发现没有相同的;
继续,str2中的“o”再与str1中的每个字符比较,发现仍然没有相同的;
继续,……
当继续到str2中的字符“k”时,在与str1中索引位置为5的字符比较时第一次发现相等,终止搜索,返回索引值5;
结束。
第二种情形(匹配失败):
#include <string.h>
#include <stdio.h>
int main()
...{
char *str1="aaaaakkkeeee"; //str1与str2中没有相同的字符
char *str2="bbbcccddd";
int inttemp;
inttemp=strcspn(str1,str2); //用strcspn函数
printf("The first index of the character both in str1 and str2: %d ", inttemp);
return 0;
}
#include <stdio.h>
int main()
...{
char *str1="aaaaakkkeeee"; //str1与str2中没有相同的字符
char *str2="bbbcccddd";
int inttemp;
inttemp=strcspn(str1,str2); //用strcspn函数
printf("The first index of the character both in str1 and str2: %d ", inttemp);
return 0;
}
在VC++ 6.0编译运行:
由于str1与str2中没有相同的字符,匹配失败,返回字符串str1的长度12。
- strcspn函数
- strcspn() 函数
- strcspn () 函数
- strcspn函数
- strcspn函数
- strcspn函数
- strcspn函数
- strspn函数 strcspn函数
- strspn函数&&strcspn函数
- strspn strcspn 函数
- strcspn和strspn函数
- strcspn和strspn函数
- strspn()函数和strcspn()函数
- strcspn
- strcspn
- 一天一个CRT函数 strcspn
- 一天一个CRT函数 strcspn
- C语言之strcspn函数
- CRUD for user and other things to do...
- gimp的python控制台以及python的PIL图像处理库
- 点击<a href="#"/>后屏幕滚动问题
- DateTime在ExtJs中无法正确序列化的问题
- sqlite语句标准
- strcspn函数
- havlenapetr-FFMpeg移植到android2.3
- SAP EXCEL OLE常用方法和属性
- gtk+ pango学习资料
- Rock Paper Azure Challenge春季比赛来了!
- strdup函数
- dms代码
- 大数乘法
- GCD介绍(二): 多核心的性能