ctype.h头文件所包含的一些函数及其用法
2012-07-18 20:03
323 查看
1 字符测试函数
1> 函数原型均为int isxxxx(int)
2> 参数为int, 任何实参均被提升成整型
3> 只能正确处理处于[0, 127]之间的值
2 字符映射函数
1> 函数原型为int toxxxx(int)
2> 对参数进行检测, 若符合范围则转换, 否则不变
int tolower(int); 'A'~'Z' ==> 'a'~'z'
int toupper(int); 'a'~'z' ==> 'A'~'Z'
@函数名称: isalpha
函数原型: int isalpha(int ch);
函数功能: 检查ch是否是字母.
函数返回: 是字母返回1 ,否则返回 0.
参数说明:
所属文件 <ctype.h>
@函数名称: iscntrl
函数原型: int iscntrl(int ch);
函数功能: 检查ch是否控制字符(其ASCII码在0和0x1F之间,数值为 0-31).
函数返回: 是返回 1,否则返回 0.
参数说明:
所属文件: <ctype.h>
@函数名称: isdigit
函数原型: int isdigit(int ch);
函数功能: 检查ch是否是数字(0-9)
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isgraph
函数原型: int isgraph(int ch);
函数功能: 检查ch是否可显示字符(其ASCII码在ox21到ox7E之间),不包括空格
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: islower
函数原型: int islower(int ch);
函数功能: 检查ch是否小写字母(a-z)
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: tolower
函数原型: int tolower(int ch);
函数功能: 将ch字符转换为小写字母
函数返回: 返回ch所代表的字符的小写字母
参数说明:
所属文件: <ctype.h>
@函数名称: toupper
函数原型: int toupper(int ch);
函数功能: 将ch字符转换成大写字母
函数返回: 与ch相应的大写字母
参数说明:
所属文件: <ctype.h>
@函数名称: isalnum
函数原型: int isalnum(int ch);
函数功能: 检查ch是否是字母或数字
函数返回: 是字母或数字返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isprint
函数原型: int isprint(int ch);
函数功能: 检查ch是否是可打印字符(包括空格),其ASCII码在ox20到ox7E之间
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: ispunct
函数原型: int ispunct(int ch);
函数功能: 检查ch是否是标点字符(不包括空格),即除字母,数字和空格以外的所有可打印字符
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isspace
函数原型: int isspace(int ch);
函数功能: 检查ch是否是空格符和跳格符(控制字符)或换行符
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isupper
函数原型: int isupper(int ch);
函数功能: 检查ch是否是大写字母(A-Z)
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isxdigit
函数原型: int isxdigit(int ch);
函数功能: 检查ch是否是一个16进制数学字符(即0-9,或A-F,或a-f)
函数返回: 是返回 1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isascii
函数原型: int isascii(int ch)
函数功能: 测试参数是否是ASCII码0-127
函数返回: 非零-是,0-不是
参数说明: ch-被测参数
所属文件: <ctype.h>
1> 函数原型均为int isxxxx(int)
2> 参数为int, 任何实参均被提升成整型
3> 只能正确处理处于[0, 127]之间的值
2 字符映射函数
1> 函数原型为int toxxxx(int)
2> 对参数进行检测, 若符合范围则转换, 否则不变
int tolower(int); 'A'~'Z' ==> 'a'~'z'
int toupper(int); 'a'~'z' ==> 'A'~'Z'
@函数名称: isalpha
函数原型: int isalpha(int ch);
函数功能: 检查ch是否是字母.
函数返回: 是字母返回1 ,否则返回 0.
参数说明:
所属文件 <ctype.h>
#include <stdio.h> #include <ctype.h> int main() { char ch1='*'; char ch2='a'; if(isalnum(ch1)!=0 printf("%c is the ASCII number or alphebet\n",ch1); else printf("%c is not the ASCII number nor alphebet\n",ch1); if(isalnum(ch2)!=0) printf("%c is the ASCII number or alphebet\n",ch2); else printf("%c is not the ASCII number nor alphebet\n",ch2); return 0; }
@函数名称: iscntrl
函数原型: int iscntrl(int ch);
函数功能: 检查ch是否控制字符(其ASCII码在0和0x1F之间,数值为 0-31).
函数返回: 是返回 1,否则返回 0.
参数说明:
所属文件: <ctype.h>
#include <stdio.h> #include <ctype.h> char chars[]={'A',0x09,'Z'}; #define SIZE sizeof(chars)/sizeof(char) int main() { int i; for(i=0;i<SIZE;i++) { printf("Char %c is %sa Control character\n",chars, (iscntrl (chars))?"":"not"); } return 0; }
@函数名称: isdigit
函数原型: int isdigit(int ch);
函数功能: 检查ch是否是数字(0-9)
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isgraph
函数原型: int isgraph(int ch);
函数功能: 检查ch是否可显示字符(其ASCII码在ox21到ox7E之间),不包括空格
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: islower
函数原型: int islower(int ch);
函数功能: 检查ch是否小写字母(a-z)
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: tolower
函数原型: int tolower(int ch);
函数功能: 将ch字符转换为小写字母
函数返回: 返回ch所代表的字符的小写字母
参数说明:
所属文件: <ctype.h>
@函数名称: toupper
函数原型: int toupper(int ch);
函数功能: 将ch字符转换成大写字母
函数返回: 与ch相应的大写字母
参数说明:
所属文件: <ctype.h>
@函数名称: isalnum
函数原型: int isalnum(int ch);
函数功能: 检查ch是否是字母或数字
函数返回: 是字母或数字返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isprint
函数原型: int isprint(int ch);
函数功能: 检查ch是否是可打印字符(包括空格),其ASCII码在ox20到ox7E之间
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: ispunct
函数原型: int ispunct(int ch);
函数功能: 检查ch是否是标点字符(不包括空格),即除字母,数字和空格以外的所有可打印字符
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isspace
函数原型: int isspace(int ch);
函数功能: 检查ch是否是空格符和跳格符(控制字符)或换行符
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isupper
函数原型: int isupper(int ch);
函数功能: 检查ch是否是大写字母(A-Z)
函数返回: 是返回1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isxdigit
函数原型: int isxdigit(int ch);
函数功能: 检查ch是否是一个16进制数学字符(即0-9,或A-F,或a-f)
函数返回: 是返回 1,否则返回0
参数说明:
所属文件: <ctype.h>
@函数名称: isascii
函数原型: int isascii(int ch)
函数功能: 测试参数是否是ASCII码0-127
函数返回: 非零-是,0-不是
参数说明: ch-被测参数
所属文件: <ctype.h>
相关文章推荐
- ctype.h包含的相关函数的用法
- ctype.h包含的相关函数的用法
- Matlab中一些函数及其用法列表
- ctype.h中的函数及其用法
- 学习matlab中遇到的一些函数及其用法
- sort()函数与qsort()函数及其头文件
- 关于C++中函数指针的使用(包含对typedef用法的讨论)
- tensorflow一些函数用法笔记
- prototype.js常用函数及其用法
- XML 包含函数fn:contains(string1,string2)的用法
- scikit-learn常用的一些函数及在实战中的用法
- 定义一个长度大于5,包含字符‘@’的字符串,完成如下操作......(foreach及各种函数的用法)
- MySQL自定义函数用法详解-复合结构自定义变量/流程控制--及其相关案例
- Hive 中的复合数据结构简介以及一些函数的用法说明
- sort()函数与qsort()函数及其头文件
- 一些常见函数的用法
- prototype.js常用函数及其用法
- prototype.js常用函数及其用法
- numpy中一些函数的用法
- C语言中常用库函数及其用法-sscanf()