首页 / 软件开发 / C语言 / C字符串函数strpbrk
C字符串函数strpbrk2010-05-06原型:extern char *strpbrk(char *s1, char *s2);用法:#include <string.h>功能:在字符串s1中寻找字符串s2中任何一个字符相匹配的第一个字符的位置,空字符NULL不包括在内。说明:返回指向s1中第一个相匹配的字符的指针,如果没有匹配字符则返回空指针NULL。举例:// strpbrk.c
#include <syslib.h>
#include <string.h>
main()
{
char *s1="Welcome To Beijing";
char *s2="BIT";
char *p;
clrscr();
p=strpbrk(s1,s2);
if(p)
printf("%s
",p);
else
printf("Not Found!
");
p=strpbrk(s1, "Da");
if(p)
printf("%s",p);
else
printf("Not Found!");
getchar();
return 0;
}
相关函数:strcspn,strtok