专业设计企业网站/微信管理软件哪个最好
原型
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"中任意字符的位置,找到echar *p2 = strpbrk(sStr1,sStr3); //去sStr1搜索包含"Tst"中任意字符的位置,没找到cout<<p<<endl;cout<<(p2==NULL?"NULL":"NOT NULL")<<endl;
}
结果:
en Global View
NULL