阅读(2227) (24)

strcspn

2015-11-11 16:00:33 更新

 原型:extern int strcspn(char *s1,char *s2);
       
 用法:#include <string.h>
 
 功能:在字符串s1中搜寻s2中所出现的字符。
 
 说明:返回第一个出现的字符在s1中的下标值,亦即在s1中出现而s2中没有出现的子串的长度。
 
 举例:


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