mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 23:14:06 +08:00
47 lines
1.1 KiB
HTML
47 lines
1.1 KiB
HTML
<h1>字符串函数 - strpbrk</h1>
|
||
|
||
|
||
<p>原型:extern char *strpbrk(char *s1, char *s2);</p>
|
||
|
||
<p>用法:#include <string.h></p>
|
||
|
||
<p>功能:在字符串s1中寻找字符串s2中任何一个字符相匹配的第一个字符的位置,空字符NULL不包括在内。</p>
|
||
|
||
<p>说明:返回指向s1中第一个相匹配的字符的指针,如果没有匹配字符则返回空指针NULL。</p>
|
||
|
||
|
||
举例:<pre><code class="language-c">
|
||
|
||
|
||
// 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\n",p);
|
||
else
|
||
printf("Not Found!\n");
|
||
|
||
p=strpbrk(s1, "Da");
|
||
if(p)
|
||
printf("%s",p);
|
||
else
|
||
printf("Not Found!");
|
||
|
||
getchar();
|
||
return 0;
|
||
}
|
||
|
||
</code></pre>相关函数:<a href="strcspn.html">strcspn</a>,<a href="strtok.html">strtok</a>
|
||
|