首页 > 其他 > 详细

cctype 头文件定义函数

时间:2014-05-23 22:03:35      阅读:683      评论:0      收藏:0      [点我收藏+]
header

<cctype> (ctype.h)

Character handling functions

This header declares a set of functions to classify and transform individual characters.

Functions

These functions take the int equivalent of one character as parameter and return an int that can either be another character or a value representing a boolean value: an int value of 0 means false, and an int value different from 0represents true.

There are two sets of functions:

Character classification functions

They check whether the character passed as parameter belongs to a certain category:

 

Character conversion functions

Two functions that convert between letter cases:


For the first set, here is a map of how the original 127-character ASCII set is considered by each function (an x indicates that the function returns true on that character)

ASCII values characters iscntrl isblank isspace isupper islower isalpha isdigit isxdigit isalnum ispunct isgraph isprint
0x00 .. 0x08 NUL, (other control codes) x                      
0x09 tab (‘\t‘) x x x                  
0x0A .. 0x0D (white-space control codes:‘\f‘,‘\v‘,‘\n‘,‘\r‘) x   x                  
0x0E .. 0x1F (other control codes) x                      
0x20 space (‘ ‘)   x x                 x
0x21 .. 0x2F !"#$%&‘()*+,-./                   x x x
0x30 .. 0x39 0123456789             x x x   x x
0x3a .. 0x40 :;<=>?@                   x x x
0x41 .. 0x46 ABCDEF       x   x   x x   x x
0x47 .. 0x5A GHIJKLMNOPQRSTUVWXYZ       x   x     x   x x
0x5B .. 0x60 [\]^_`                   x x x
0x61 .. 0x66 abcdef         x x   x x   x x
0x67 .. 0x7A ghijklmnopqrstuvwxyz         x x     x   x x
0x7B .. 0x7E {|}~                   x x x
0x7F (DEL) x                      


The characters in the extended character set (above 0x7F) may belong to diverse categories depending on the locale and the platform. As a general rule, ispunctisgraph and isprint return true on these for the standard C locale on most platforms supporting extended character sets.

 

 cctype 头文件所包含的函数主要用来测试字符值。

 

isalnum(c) 假如c是字母或数字,则为true
isalpah(c) 假如c是字母,则为true
iscntrl(c) 假如c是控制字符,则为true
isdigit(c) 假如c是数字,则为true
isgraph(c) 假如c不是空格,则为true
islower(c) 假如c是小写字母,则为true
isprint(c) 假如c是可打印的字符,则为true
ispunct(c) 假如c是标点符号,则为true
isspace(c) 假如c是空白字符,则为true
isupper(c) 假如c是大写字母,则为true
isxdigit(c) 假如c是十六进制数,则为true
tolower(c) 假如c是大写字母,则返回小写字母形式,否则返回c。
toupper(c) 假如c是小写字母,则返回大些字母形式,否则返回c。

cctype 头文件定义函数,布布扣,bubuko.com

cctype 头文件定义函数

原文:http://www.cnblogs.com/leadtheway/p/3737019.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!