strpbrk

来源:互联网 发布:软件测试书籍电子版 编辑:程序博客网 时间:2024/05/17 20:29

原型

char *strpbrk(char *str1, char *str2)


功能

比较字符串str1中是否有str2中的字符。


返回值

如果找到,则返回str1中该字符位置的指针。
如果没找对,则返回NULL


示例

#include <string.h>#include <iostream.h>void main(void){    char sStr1[100],sStr2[100],sStr3[100];    sStr1[0] = sStr2[0] = '\0';    strcpy(sStr1,"Golden Global View");    strcpy(sStr2,"Test");    strcpy(sStr3,"Tst");    char *p = strpbrk(sStr1,sStr2);   //去sStr1搜索包含"Test"中任意字符的位置,找到e    char *p2 = strpbrk(sStr1,sStr3); //去sStr1搜索包含"Tst"中任意字符的位置,没找到    cout<<p<<endl;    cout<<(p2==NULL?"NULL":"NOT NULL")<<endl;}


结果:
en Global View

NULL


0 0
原创粉丝点击