Files
uTools-Manuals/docs/c/strcspn.html
T
fofolee 38dcd51d8a v0.0.2
2019-04-21 11:50:48 +08:00

37 lines
867 B
HTML

<h1>字符串函数 - strcspn</h1>
<p>原型:extern int strcspn(char *s1,char *s2);</p>
<p>用法:#include &lt;string.h></p>
<p>功能:在字符串s1中搜寻s2中所出现的字符。</p>
<p>说明:返回第一个出现的字符在s1中的下标值,亦即在s1中出现而s2中没有出现的子串的长度。</p>
举例:<pre><code class="language-c">
// strcspn.c
#include &lt;syslib.h>
#include &lt;string.h>
main()
{
char *s="Golden Global View";
char *r="new";
int n;
clrscr();
n=strcspn(s,r);
printf("The first char both in s1 and s2 is: %c",s[n]);
getchar();
return 0;
}
</code></pre>相关函数:<a href="strpbrk.html">strpbrk</a>