跳轉到內容

簡易 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.
華夏公益教科書