- 判断一个字符是否是十进制数组
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include "stdio.h" #include "ctype.h" unsigned char s[] = "1234567890abc"; int main(void) { int i = 0; while(s[i] != '') { if(isdigit(s[i])) { printf("%c is a num.n",s[i]); } else { printf("%c is not a num.n",s[i]); } i++; } printf("%dn",sizeof(s)); return 0; }
执行结果:
- .是否是字母测试
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20void isalpha_test(void) { unsigned char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123!@'"; int i = 0; while(s[i] != '') { if(isalpha(s[i])) { printf("%c is a alpha.n",s[i]); } else { printf("%c is a not alpha.n",s[i]); } i++; } }
测试结果:
- 数字以及字母检测
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18void isalnum_test(void) { unsigned char s[] = "abcDFG1230x88_+-"; int i = 0; while(s[i] != '') { if(isalnum(s[i])) { printf("%c is alnum.n",s[i]); } else { printf("%c is not alnum.n",s[i]); } i++; } }
运行结果:
时间有点晚了,今天总结到此。
最后
以上就是无限悟空最近收集整理的关于069_ctype库函数的使用-1的全部内容,更多相关069_ctype库函数内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复