非常教程

C 教程教程

C 库函数 – strcspn()

C 库函数 – strcspn()

C 库函数 - strcspn()

C 库函数 – strcspn()

C 标准库 - <string.h>

描述

C 库函数 size_t strcspn(const char *str1, const char *str2) 检索字符串 str1 开头连续有几个字符都不含字符串 str2 中的字符。

声明

下面是 strcspn() 函数的声明。

size_t strcspn(const char *str1, const char *str2)

参数

  • str1 -- 要被检索的 C 字符串。
  • str2 -- 该字符串包含了要在 str1 中进行匹配的字符列表。

返回值

该函数返回 str1 开头连续都不含字符串 str2 中字符的字符数。

实例

下面的实例演示了 strcspn() 函数的用法。

#include <stdio.h>
#include <string.h>


int main ()
{
   int len;
   const char str1[] = "ABCDEF4960910";
   const char str2[] = "013";

   len = strcspn(str1, str2);

   printf("第一个匹配的字符是在 %d\n", len + 1);
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

第一个匹配的字符是在 10

C 库函数 – strcspn()

C 标准库 - <string.h>

C 库函数 – strcspn()
C 教程

C 语言是一种通用的、面向过程式的计算机程序设计语言,广泛用于系统与应用软件的开发。具有高效、灵活、功能丰富、表达力强和较高的可移植性等特点,在程序员中备受青睐。

C 教程目录

1.C 基本语法
2.C 程序结构
3.C 环境设置
4.C 简介
5.C 作用域规则
6.C 函数
7.C 运算符
8.C 存储类
9.C 常量
10.C 头文件
11.C 预处理器
12.C 文件读写
13.C 输入 & 输出
14.C typedef
15.C 位域
16.C 共用体
17.C 结构体
18.C 指针
19.C 命令行参数
20.C 内存管理
21.C 可变参数
22.C 错误处理
23.C do…while 循环
24.C for 循环
25.C while 循环
26.C 嵌套 switch 语句
27.C switch 语句
28.C 嵌套 if 语句
29.C if…else 语句
30.C if 语句
31.C 指向数组的指针
32.C 从函数返回数组
33.C 传递数组给函数
34.C 多维数组
35.C 引用方式调用函数
36.C 传值方式调用函数
37.C goto 语句
38.C continue 语句
39.C break 语句
40.C 嵌套循环
41.C 从函数返回指针
42.C 传递指针给函数
43.C 指向指针的指针
44.C 指针数组
45.C 指针的算术运算
46.C 标准库 – <limits.h>
47.C 标准库 – <setjmp.h>
48.C 标准库 – <float.h>
49.C 标准库 – <errno.h>
50.C 标准库 – <ctype.h>
51.C 标准库 – <assert.h>
52.C 标准库 – 参考手册
53.C 库宏 – assert()
54.C 标准库 – <time.h>
55.C 标准库 – <string.h>
56.C 标准库 – <stdlib.h>
57.C 标准库 – <stdio.h>
58.C 标准库 – <stddef.h>
59.C 标准库 – <stdarg.h>
60.C 标准库 – <signal.h>
61.C 标准库 – <math.h>
62.C 标准库 – <locale.h>
63.C 库函数 – isspace()
64.C 库函数 – ispunct()
65.C 库函数 – isprint()
66.C 库函数 – islower()
67.C 库函数 – isgraph()
68.C 库函数 – isdigit()
69.C 库函数 – iscntrl()
70.C 库函数 – isalpha()
71.C 库函数 – isalnum()
72.C 库函数 – setlocale()
73.C 库宏 – ERANGE
74.C 库宏 – EDOM
75.C 库宏 – errno
76.C 库函数 – toupper()
77.C 库函数 – tolower()
78.C 库函数 – isxdigit()
79.C 库函数 – isupper()
80.C 库函数 – tanh()
81.C 库函数 – sinh()
82.C 库函数 – sin()
83.C 库函数 – cosh()
84.C 库函数 – cos()
85.C 库函数 – atan2()
86.C 库函数 – atan()
87.C 库函数 – asin()
88.C 库函数 – acos()
89.C 库函数 – localeconv()
90.C 库函数 – fabs()
91.C 库函数 – ceil()
92.C 库函数 – sqrt()
93.C 库函数 – pow()
94.C 库函数 – modf()
95.C 库函数 – log10()
96.C 库函数 – log()
97.C 库函数 – ldexp()
98.C 库函数 – frexp()
99.C 库函数 – exp()
100.C 库函数 – fmod()