mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 06:55:36 +08:00
37 lines
831 B
HTML
37 lines
831 B
HTML
<h1>字符串函数 - strcspn</h1>
|
||
|
||
|
||
<p>原型:extern int strcspn(char *s1,char *s2);</p>
|
||
|
||
<p>用法:#include <string.h></p>
|
||
|
||
<p>功能:在字符串s1中搜寻s2中所出现的字符。</p>
|
||
|
||
<p>说明:返回第一个出现的字符在s1中的下标值,亦即在s1中出现而s2中没有出现的子串的长度。</p>
|
||
|
||
举例:<pre><code class="language-c">
|
||
|
||
|
||
// strcspn.c
|
||
|
||
#include <syslib.h>
|
||
#include <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>
|
||
|