跳转到内容

简易 C Primer/C 字符类测试库

来自维基教科书,面向开放世界的开放书籍

这些函数对字符执行各种测试。它们需要以下声明

   #include <ctype.h>

该字符表示为“int”,并且函数返回“int”。如果测试为假,则返回 0;如果测试为真,则返回非 0

   isalnum( c )     Character is alpha or digit.
   isalpha( c )     Character is alpha.
   iscntrl( c )     Character is control character.
   isdigit( c )     Character is decimal digit.
   isgraph( c )     Character is printing character (except space).
   islower( c )     Character is lower-case.
   isprint( c )     Character is printing character (including space).
   ispunct( c )     Character is printing character but not space/alpha-digit.
   isspace( c )     Character is space, FF, LF, CR, HT, VT.
   isupper( c )     Character is upper-case.
   isxdigit( c )    Character is hex digit.

该库还包含两个转换函数,它们也接受并返回“int”

   tolower( c )    Convert to lower case.
   toupper( c )    Convert to upper case.
华夏公益教科书