strcspn

王朝百科·作者佚名  2010-02-17
窄屏简体版  字體: |||超大  

原型:size_t strcspn(const char *s1,const char *s2);

相关头文件:#include <string.h>

功能:在字符串s1中搜寻s2中所出现的字符,返回s2中出现的第一个字符在S1中出现的位置。

说明:(返回第一个出现的字符在s1中的下标值,亦即在s1中出现而s2中没有出现的子串的长度。)

简单地说,若strcspn()返回的数值为n,则代表字符串s开头连续有n个字符都不含字符串reject内的字符。

举例:

// strcspn.c

#include <stdio.h >

#include <syslib.h>

#include <string.h>

int main(void)

{

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;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航