strpbrk函数
http://blog.csdn.net/tommy_wxie/article/details/7554332
函數(shù)原型:extern char *strpbrk(char *str1, char *str2)
參數(shù)說明:str1待比較的字符串,str2為指定被搜索的字符串。
????????
所在庫名:#include <string.h>
??
函數(shù)功能:比較字符串str1和str2中是否有相同的字符,如果有,則返回該字符在str1中的位置的指針。
??
返回說明:返回指針,搜索到的字符在str1中的索引位置的指針。
其它說明:暫時無。
實例:
#include<string.h>#include<stdio.h>
int?main()
...{
????char?*str1="please?try?again,sky2098!";
????char?*str2="Hello,I?am?sky2098,I?like?writing!";
????char?*strtemp;
????strtemp=strpbrk(str1,str2);??//搜索進(jìn)行匹配
????printf("Result?is: ?%s?",strtemp);
????return?0;
}
在VC++ 6.0? 編譯運行:
返回了str2中字符“l(fā)”在str1中位置的指針,打印出字符串“lease?try?again,sky2098!”。
如果str2中所有字符都沒有在str1中出現(xiàn)過,則返回null:
#include<string.h>#include<stdio.h>
int?main()
...{
????char?*str1="aaaaaaabbbbbbbcccccccc";??//str1中的任何一個字符在str2中都找不到
????char?*str2="ppppkkkkmmmer";
????char?*strtemp;
????strtemp=strpbrk(str1,str2);
????printf("Result?is: ?%s?",strtemp);
????return?0;
}
在VC++ 6.0? 編譯運行:
返回了空值。
總結(jié)
- 上一篇: 输卵管堵塞表现是什么
- 下一篇: 随机生成1024个数,存入一段内存,用指