我是靠谱客的博主 无限悟空,这篇文章主要介绍069_ctype库函数的使用-1,现在分享给大家,希望可以做个参考。

  1. 判断一个字符是否是十进制数组
复制代码
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. .是否是字母测试
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void 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. 数字以及字母检测
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void 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库函数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部