字符串函数strpbrk

原型:extern char *strpbrk(char *s1, char *s2);

用法:#include <string.h>

功能:在字符串s1中寻找字符串s2中任何一个字符相匹配的第一个字符的位置,空字符NULL不包括在内。

说明:返回指向s1中第一个相匹配的字符的指针,如果没有匹配字符则返回空指针NULL。

举例:

   // strpbrk.c
   
   #include <syslib.h>
   #include <string.h>
   int main(void)
   {
    char *s1="Welcome To Beijing";
    char *s2="BIT";
    char *p;
    
    clrscr();
        
    p=strpbrk(s1,s2);
    if(p)
     printf("%sn",p);
    else
     printf("Not Found!n");
    p=strpbrk(s1, "Da");
    if(p)
     printf("%s",p);
    else
     printf("Not Found!");


    getchar();


    return 0;
   }

 

你可能感兴趣的:(字符串函数strpbrk)