当前位置: 首页 > news >正文

【C语法学习】28 - 字符测试函数

文章目录

  • 1 isalnum()函数
  • 2 isalpha()函数
  • 3 islower()函数
  • 4 isupper()函数
  • 5 isdigit()函数
  • 6 isxdigit()函数
  • 7 iscntrl()函数
  • 8 isgraph()函数
  • 9 isspace()函数
  • 10 isblank()函数
  • 11 isprintf()函数

1 isalnum()函数

isalnum()函数检测ch是否是字母和数字,函数原型如下:

int isalnum(int ch);

C语言标准描述如下:

1. Checks if the given character is an alphanumeric character as classified by the current C locale. In the default locale, the following characters are alphanumeric:(1) digits (0123456789)(2) uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)(3) lowercase letters (abcdefghijklmnopqrstuvwxyz)
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is an alphanumeric character, 0 otherwise.

2 isalpha()函数

isalpha()函数检测ch是否是字母,函数原型如下:

int isalpha(int ch);

C语言标准描述如下:

1. Checks if the given character is an alphabetic character, i.e. either an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), or a lowercase letter (abcdefghijklmnopqrstuvwxyz).
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is an alphabetic character, zero otherwise.

3 islower()函数

islower()函数检测ch是否为小写字母,函数原型如下:

int islower(int ch);

C语言标准描述如下:

1. Checks if the given character is classified as a lowercase character according to the current C locale. In the default "C" locale, islower returns true only for the lowercase letters (abcdefghijklmnopqrstuvwxyz).
2. If islower returns true, it is guaranteed that iscntrl, isdigit, ispunct, and isspace return false for the same character in the same C locale.
3. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
4. Non-zero value if the character is a lowercase letter, zero otherwise.

4 isupper()函数

isupper()函数检测ch是否为大写字母,函数原型如下:

int isupper(int ch);

C语言标准描述如下:

1. Checks if the given character is an uppercase character according to the current C locale. In the default "C" locale, isupper returns true only for the uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ).
2. If isupper returns true, it is guaranteed that iscntrl, isdigit, ispunct, and isspace return false for the same character in the same C locale.
3. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
4. Non-zero value if the character is an uppercase letter, zero otherwise.

5 isdigit()函数

isdigit()函数检测ch是否为十进制数字,函数原型如下:

int isdigit(int ch);

C语言标准描述如下:

1. Checks if the given character is a numeric character (0123456789).
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is a numeric character, zero otherwise.

6 isxdigit()函数

isxdigit()函数检测ch是否为十六进制数字,函数原型如下:

int isxdigit(int ch);

C语言标准描述如下:

1. Checks if the given character is a hexadecimal numeric character (0123456789abcdefABCDEF) or is classified as a hexadecimal character.
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is an hexadecimal numeric character, zero otherwise.

7 iscntrl()函数

iscntrl()函数检测ch是否为控制字符,函数原型如下:

int iscntrl(int ch);

C语言标准描述如下:

1. Checks if the given character is a control character, i.e. codes 0x00-0x1F and 0x7F.
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is a control character, zero otherwise.

8 isgraph()函数

isgraph()函数检测ch是否有图形表示,函数原型如下:

int isgraph(int ch);

C语言标准描述如下:

1. Checks if the given character has a graphical representation, i.e. it is either a number (0123456789), an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), a lowercase letter (abcdefghijklmnopqrstuvwxyz), or a punctuation character (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~), or any graphical character specific to the current C locale.
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character has a graphical representation character, zero otherwise.

9 isspace()函数

isspace()函数检测ch是否是空白字符,函数原型如下:

int isspace(int ch);

C语言标准描述如下:

1. Checks if the given character is either(1) A standard white-space character:(2) Space (0x20, ' '),(3) Form feed (0x0c, '\f'),(4) Line feed (0x0a, '\n'),(5) Carriage return (0x0d, '\r'),(6) Horizontal tab (0x09, '\t'),(7) Vertical tab (0x0b, '\v'),(8) Or a locale-specific white-space character.
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is a whitespace character, zero otherwise.

10 isblank()函数

isblank()函数检测ch是否为空白字符,函数原型如下:

int isblank(int ch);

C语言标准描述如下:

1. Checks if the given character is a blank character in the current C locale. In the default C locale, only space (0x20) and horizontal tab (0x09) are classified as blank.
2. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
3. Non-zero value if the character is a blank character, zero otherwise.

11 isprintf()函数

相关文章:

  • C++ Day04 this指针,友元函数,重载
  • Hadoop学习总结(MapReduce的数据去重)
  • 基于安卓android微信小程序的刷题系统
  • K8S部署mongodb-sharded-cluster(7.0.2)副本分片
  • 技术面时,一定要掌握这3个关键点
  • MySQL-02-InnoDB存储引擎
  • 22款奔驰S400L升级原厂360全景影像 高清环绕 无死角
  • 【php】解决加载速度慢导出超时问题记录
  • STM32分区跳转问题
  • docker-compose 服务编排
  • 企业微信身份验证
  • 2023全球数字贸易创新大赛-人工智能元宇宙-11-12,数据二十条,数字产业化和产业数字化
  • 【bug】uniapp的image组件渲染gif图,只有第一次点击的时候有动效,需要每次点击都有gif效果,已解决
  • 【音视频-FFMPEG相关命令使用】
  • SELinux零知识学习二十五、SELinux策略语言之类型强制(10)
  • 【前端学习】-粗谈选择器
  • 07.Android之多媒体问题
  • Angular js 常用指令ng-if、ng-class、ng-option、ng-value、ng-click是如何使用的?
  • create-react-app做的留言板
  • Django 博客开发教程 8 - 博客文章详情页
  • github指令
  • Intervention/image 图片处理扩展包的安装和使用
  • JavaScript设计模式与开发实践系列之策略模式
  • JavaScript新鲜事·第5期
  • JSDuck 与 AngularJS 融合技巧
  • js算法-归并排序(merge_sort)
  • Redux系列x:源码分析
  • Ruby 2.x 源代码分析:扩展 概述
  • 百度贴吧爬虫node+vue baidu_tieba_crawler
  • 构建二叉树进行数值数组的去重及优化
  • 记录:CentOS7.2配置LNMP环境记录
  • 力扣(LeetCode)357
  • 如何邀请好友注册您的网站(模拟百度网盘)
  • 时间复杂度与空间复杂度分析
  • 物联网链路协议
  • 400多位云计算专家和开发者,加入了同一个组织 ...
  • ​创新驱动,边缘计算领袖:亚马逊云科技海外服务器服务再进化
  • # 执行时间 统计mysql_一文说尽 MySQL 优化原理
  • #NOIP 2014# day.1 T3 飞扬的小鸟 bird
  • (Matlab)遗传算法优化的BP神经网络实现回归预测
  • (PHP)设置修改 Apache 文件根目录 (Document Root)(转帖)
  • (九)c52学习之旅-定时器
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (四)c52学习之旅-流水LED灯
  • (原創) 是否该学PetShop将Model和BLL分开? (.NET) (N-Tier) (PetShop) (OO)
  • (转贴)用VML开发工作流设计器 UCML.NET工作流管理系统
  • .360、.halo勒索病毒的最新威胁:如何恢复您的数据?
  • .Net Remoting(分离服务程序实现) - Part.3
  • @Query中countQuery的介绍
  • [<事务专题>]
  • [2024最新教程]地表最强AGI:Claude 3注册账号/登录账号/访问方法,小白教程包教包会
  • [BUUCTF 2018]Online Tool
  • [c++] 什么是平凡类型,标准布局类型,POD类型,聚合体
  • [FTP]pureftp部署和优化
  • [HDU5685]Problem A