我是靠谱客的博主 无限悟空,最近开发中收集的这篇文章主要介绍069_ctype库函数的使用-1,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

  1. 判断一个字符是否是十进制数组
#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. .是否是字母测试

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. 数字以及字母检测
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库函数的使用-1所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部