zoukankan      html  css  js  c++  java
  • c语言字符类别测试库函数#include<ctype.h>

    字符类测试<ctype.h>

    头文件<ctype.h>中说明了一些用于测试字符的函数。每个函数的变量均为int类型,变量的值必须是EOF或可用unsigned char类型表示的字符,函数的返回值为int类型。如果变量满足所指定的条件,那么函数返回非0值(表示真);否则返回值为0(表示假)。这些函数包括2.1~2.11。

    在7位ASCII字符集中,可打印字符是从0x20(' ')到0x7E('~')之间的字符;控制字符是从0(NUL)到0x1F(US)之间的字符和字符0x7F(DEL)。

    1 isalnum

    #include <ctype.h>
    int sialnum(int ch);

    变量为字母或数字时,函数返回非0值,否则返回0。

    2 isalpha

    #include <ctype.h>
    int isalpha(int ch);

    当变量为字母表中的字母时,函数返回非0值,否则返回0。各种语言的字母表互不相同,对于英语来说,字母表由大写和小写的字母A到Z组成。

    3 iscntrl

    #include <ctype.h>
    int iscntrl(int ch);

    当变量是控制字符时,函数返回非0,否则返回0。

    4 isdigit

    #include <ctype.h>
    int isdigit(int ch);

    当变量是十进制数字时,函数返回非0值,否则返回0。

    5 isgraph

    #include <ctype.h>
    int isgraph(int ch);

    如果变量为除空格之外的任何可打印字符,则函数返回非0值,否则返回0。

    6 islower

    #include <ctype.h>
    int islower(int ch);

    如果变量是小写字母,函数返回非0值,否则返回0。

    7 isprint

    #include <ctype.h>
    int isprint(int ch);

    如果变量是可打印字符(含空格),则函数返回非0值,否则返回0。

    8 ispunct

    #include <ctype.h>
    int ispunct(int ch);

    如果变量是除空格、字母和数字外的可打印字符,则函数返回非0,否则返回0。

    9 isspace

    #include <ctype.h>
    int isspace(int ch);

    当变量为空白字符(包括空格、换页符、换行符、回车符、水平制表符和垂直制表符)时,函数返回非0,否则返回0。

    10 isupper

    #include <ctype.h>
    int isupper(int ch);

    如果变量为大写字母,函数返回非0,否则返回0。

    11 isxdigit

    #include <ctype.h>
    int isxdigit(int ch);

    当变量为十六进制数字时,函数返回非0,否则返回0。

    12 tolower

    #include <ctype.h>
    int tolower(int ch);

    当ch为大写字母时,返回其对应的小写字母;否则返回ch。

    13 toupper

    #include <ctype.h>
    int toupper(int ch);

    当ch为小写字母时,返回其对应的大写字母;否则返回ch。

  • 相关阅读:
    SPOJ VJudge QTREE
    LCA 在线倍增法 求最近公共祖先
    Codevs 2370 小机房的树
    51Nod-1632-B君的连通
    51Nod--1100-斜率最大
    51Nod-1276-岛屿的数量
    51Nod-1270-数组的最大代价
    poj
    hihocoder Week136 -- 优化延迟
    poj-1035-Spell Checker
  • 原文地址:https://www.cnblogs.com/haore147/p/3647549.html
Copyright © 2011-2022 走看看