strcspn

2018-11-11 16:00 更新

 原型:extern int strcspn(char *s1,char *s2);
       
 用法:#include <string.h>
 
 功能:在字符串s1中搜尋s2中所出現(xiàn)的字符。
 
 說(shuō)明:返回第一個(gè)出現(xiàn)的字符在s1中的下標(biāo)值,亦即在s1中出現(xiàn)而s2中沒(méi)有出現(xiàn)的子串的長(zhǎng)度。
 
 舉例:


     // 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;
     }


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)