uTools-Manuals/docs/c/strcspn.html

37 lines
831 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>