字符测试篇isalnum isalpha isascii iscntrl isdigit isgraphis islower isprint isspace ispunct isupper isxdigit
isalnum(测试字符是否为英文或数字) 相关函数 isalpha,isdigit,islower,isupper 表头文件 #include<ctype.h> 定义函数 int isalnum (int c) 函数说明 检查参数c是否为英文字母或阿拉伯数字,在标准c中相当于使用“isalpha(c) || isdigit(c)”做测试。 返回值 若参数c为字母或数字,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /* 找出str 字符串中为英文字母或数字的字符*/ #include < ctype.h> main() { char str[]=”123c@#FDsP[e?”; int i; ;str[i]!=;i++ ) if ( isalnum(str[i])) printf(“%c is an alphanumeric character\n”,str[i]); } 执行 is an apphabetic character is an apphabetic character is an apphabetic character c is an apphabetic character F is an apphabetic character D is an apphabetic character s is an apphabetic character P is an apphabetic character e is an apphabetic character isalpha (测试字符是否为英文字母) 相关函数 isalnum,islower,isupper 表头文件 #include<ctype.h> 定义函数 int isalpha (int c) 函数说明 检查参数c是否为英文字母,在标准c中相当于使用“isupper(c)||islower(c)”做测试。 返回值 若参数c为英文字母,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /* 找出str 字符串中为英文字母的字符*/ #include <ctype.h> main() { char str[]=”123c@#FDsP[e?”; int i; ;str[i]!=;i++) if(isalpha(str[i])) printf(“%c is an alphanumeric character\n”,str[i]); } 执行 c is an apphabetic character F is an apphabetic character D is an apphabetic character s is an apphabetic character P is an apphabetic character e is an apphabetic character isascii(测试字符是否为ASCII 码字符) 相关函数 iscntrl 表头文件 #include <ctype.h> 定义函数 int isascii(int c); 函数说明 检查参数c是否为ASCII码字符,也就是判断c的范围是否在0到127之间。 返回值 若参数c为ASCII码字符,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /* 判断int i是否具有对映的ASCII码字符*/ #include<ctype.h> main() { int i; ;i<;i++) if(isascii(i)) printf("%d is an ascii character:%c\n",i,i); else printf("%d is not an ascii character\n",i); } 执行 is an ascii character:} is an ascii character:~ is an ascii character: is not an ascii character is not an ascii character iscntrl(测试字符是否为ASCII 码的控制字符) 相关函数 isascii 表头文件 #include <ctype.h> 定义函数 int iscntrl(int c); 函数说明 检查参数c是否为ASCII控制码,也就是判断c的范围是否在0到30之间。 返回值 若参数c为ASCII控制码,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 isdigit(测试字符是否为阿拉伯数字) 相关函数 isxdigit 表头文件 #include<ctype.h> 定义函数 int isdigit(int c) 函数说明 检查参数c是否为阿拉伯数字0到9。 返回值 若参数c为阿拉伯数字,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /* 找出str字符串中为阿拉伯数字的字符*/ #include<ctype.h> main() { char str[]="123@#FDsP[e?"; int i; ;str[i]!=;i++) if(isdigit(str[i])) printf("%c is an digit character\n",str[i]); } 执行 is an digit character is an digit character is an digit character isgraphis(测试字符是否为可打印字符) 相关函数 isprint 表头文件 #include <ctype.h> 定义函数 int isgraph (int c) 函数说明 检查参数c是否为可打印字符,若c所对映的ASCII码可打印,且非空格字符则返回TRUE。 返回值 若参数c为可打印字符,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /* 判断str字符串中哪些为可打印字符*/ #include<ctype.h> main() { char str[]="a5 @;"; int i; ;str[i]!=;i++) if(isgraph(str[i])) printf("str[%d] is printable character:%d\n",i,str[i]); } 执行 str[] is printable character:a str[] str[] is printable character:@ str[] is printable character:; islower(测试字符是否为小写字母) 相关函数 isalpha,isupper 表头文件 #include<ctype.h> 定义函数 int islower(int c) 函数说明 检查参数c是否为小写英文字母。 返回值 若参数c为小写英文字母,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 #include<ctype.h> main() { char str[]="123@#FDsP[e?"; int i; ;str[i]!=;i++) if(islower(str[i])) printf("%c is a lower-case character\n",str[i]); } 执行 c is a lower-case character s is a lower-case character e is a lower-case character isprint(测试字符是(否为可打印字符) 相关函数 isgraph 表头文件 #include<ctype.h> 定义函数 int isprint(int c); 函数说明 检查参数c是否为可打印字符,若c所对映的ASCII码可打印,其中包含空格字符,则返回TRUE。 返回值 若参数c为可打印字符,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /* 判断str字符串中哪些为可打印字符包含空格字符*/ #include<ctype.h> main() { char str[]="a5 @;"; int i; ;str[i]!=;i++) if(isprint(str[i])) printf("str[%d] is printable character:%d\n",i,str[i]); } 执行 str[] is printable character:a str[] str[] is printable character: str[] is printable character:@ str[] is printable character:; isspace(测试字符是否为空格字符) 相关函数 isgraph 表头文件 #include<ctype.h> 定义函数 int isspace(int c) 函数说明 检查参数c是否为空格字符,也就是判断是否为空格('')、定位字符('\t')、CR('\r')、换行('\n')、垂直定位字符('\v')或翻页('\f')的情况。 返回值 若参数c为空格字符,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /*将字符串str[]中内含的空格字符找出,并显示空格字符的ASCII码*/ #include <ctype.h> main() { char str="123c @# FD\tsP[e?\n"; int i; ;str[i]!=;i++) if(isspace(str[i])) printf("str[%d] is a white-space character:%d\n",i,str[i]); } 执行 str[] str[] str[] /* \t */ str[] /* \t */ ispunct(测试字符是否为标点符号或特殊符号) 相关函数 isspace,isdigit,isalpha 表头文件 #inlude<ctype.h> 定义函数 int ispunct(int c) 函数说明 检查参数c是否为标点符号或特殊符号。返回TRUE也就是代表参数c为非空格、非数字和非英文字母。 返回值 v若参数c为标点符号或特殊符号,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /*列出字符串str中的标点符号或特殊符号*/ #include <ctype.h> main() { char str[]="123c@ #FDsP[e?"; int i; ;str[i]!=;i++) if(ispunct(str[i])) printf("%c\n",str[i]); } 执行 v @#[? isupper(测试字符是否为大写英文字母) 相关函数 isalpha,islower 表头文件 #include<ctype.h> 定义函数 int isupper(int c) 函数说明 检查参数c是否为大写英文字母。 返回值 若参数c为大写英文字母,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /*找出字符串str中为大写英文字母的字符*/ #include <ctype.h> main() { char str[]="123c@#FDsP[e?"; int i; ;str[i]!=;i++) if(isupper(str[i])) printf("%c is an uppercase character\n",str[i]); } 执行 F is an uppercase character D is an uppercase character P is an uppercase character isxdigit(测试字符是否为16进制数字) 相关函数 isalnum,isdigit 表头文件 #include<ctype.h> 定义函数 int isxdigit (int c) 函数说明 检查参数c是否为16进制数字,只要c为下列其中一个情况则返回TRUE。16进制数字:0123456789ABCDEF。 返回值 若参数c为16进制数字,则返回TRUE,否则返回NULL()。 附加说明 此为宏定义,非真正函数。 范例 /*找出字符串str中为十六进制数字的字符*/ #include <ctype.h> main() { char str[]="123c@#FDsP[e?"; int i; ;str[i]!=;i++) if(isxdigit(str[i])) printf("%c is a hexadecimal digits\n",str[i]); } 执行 is a hexadecimal digits is a hexadecimal digits is a hexadecimal digits c is a hexadecimal digits F is a hexadecimal digits D is a hexadecimal digits e is a hexadecimal digits
字符测试篇isalnum isalpha isascii iscntrl isdigit isgraphis islower isprint isspace ispunct isupper isxdigit的更多相关文章
- Linux常用C函数---字符测试篇
函数讲解部分参考http://net.pku.edu.cn/~yhf/linux_c/ isalnum(测试字符是否为英文或数字) 相关函数 isalpha,isdigit,islower,isupp ...
- Unix/Linux环境C编程入门教程(25) C/C++字符测试那些事儿
isalnum isalpha isascii iscntrl isdigit isgraph isislower isprint isspace ispunct isupper isxdigit介绍 ...
- 字符测试与映射函数 ctype.h
对于C Standard Library 可以参考:http://www.acm.uiuc.edu/webmonkeys/book/c_guide/ 或者 http://www.cplusplus.c ...
- linux常用C函数目录
字符测试篇 isalnum isalpha isascii iscntrl isdigit isgraphis islower isprint isspace ispunct isupper isxd ...
- 归纳整理Linux下C语言常用的库函数----字符串转换、字符测试、及内存控制
在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...
- C语言中的isalpha,isdigit,islower,isupper等一系列函数
TITLE:c语言中的isalpha,isdigit,islower,isupper等一系列函数 已经全部验证检查,无任何错误 isalnum(测试字符是否为英文或数字) 相关函数 isalpha,i ...
- Maven测试篇
maven的生命周期: 讲解Maven测试篇之前将首先介绍一下Maven生命周期的相关概念,如果你熟知这部分概念可以略过此小节内容. 大多数时候,我们在构建一个项目时,不外乎是对其进行清理.编译.测 ...
- linux字符测试以及for循环
1.字符测试 常用的测试字符的命令: == .=都表示测试字符相等,格式为[ A = B ]需要注意的是变量与等号之间需要有空格,不然测试的结果不正确示例如下 若字符与等号不加空格,假设变量A=ab ...
- Java自动化测试框架-11 - TestNG之annotation与并发测试篇 (详细教程)
1.简介 TestNG中用到的annotation的快速预览及其属性. 2.TestNG基本注解(注释) 注解 描述 @BeforeSuite 注解的方法只运行一次,在当前suite所有测试执行之前执 ...
随机推荐
- Kylin使用笔记-1: 安装
2016年1月14日 9:57:23 星期四 背景介绍 Apache Kylin是一个开源的分布式分析引擎,提供Hadoop之上的SQL查询接口及多维分析(OLAP)能力以支持超大规模数据,最 ...
- git clone push需要root权限解决方法
重新装了Linux发现使用git命令必须要sudo,否则会提示权限不够. 解决办法:在ssh生成id_rsa.pub密钥时实际上有两个,根目录的家里.ssh文件夹里有一个,用户家里.sh文件夹里有一个 ...
- Linux 服务器上Redis安装和配置
1.下载安装redis 在Linux服务器上,命令行执行以下命令(cd ./usr local/src 一般源码放在这里(推荐源码安装)) wget http://download.redis.io/ ...
- poj-2253-poj-1797_最短路练习
title: poj-2253-poj-1797_最短路练习 date: 2018-11-17 11:48:51 tags: acm 刷题 categories: ACM-最短路 概述 一道最短路的变 ...
- Elasticsearch源码分析 | 单节点的启动和关闭
本文主要简要介绍Elasticsearch单节点的启动和关闭流程.Elasticsearch版本:6.3.2 相关文章 1.Google Guice 快速入门 2.Elasticsearch 中的 G ...
- Android四大组件-服务
Android服务 android 的服务有点类似windows的服务,没有界面,在后台长时间运行,如果我们这种需求的话我们就可以使用服务来实现. 服务的典型应用场景: 播放音乐,下载等,如果要在一个 ...
- 下拉框搜索插件chosen
{% load staticfiles %} <!DOCTYPE html> <html lang="en"> <head> <meta ...
- CentOS7.4 关闭firewall防火墙,改用iptables
1.关闭默认的firewall防火墙 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service ...
- 20162325 金立清 S2 W11 C20
20162325 2017-2018-2 <程序设计与数据结构>第11周学习总结 教材关键概念摘要 在哈希方法中,元素保存在哈希表中,其在表中的位置由哈希函数确定. 两个元素或关键字映射到 ...
- alpha冲刺——代码规范、冲刺任务与计划(追光的人)
代码规范 代码规范整合了自身项目实践还有诸多好的大公司的代码规范.如阿里巴巴开发手册.华为Java规范.W3C前端规范等. 由于内容过于详细和细致,为了方便查看,将其放置在了showDoc网站上(同时 ...