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

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

文章目录

  • 1 isalnum()函数
  • 2 isalpha()函数
  • 3 islower()函数
  • 4 isupper()函数
  • 5 isdigit()函数
  • 6 isxdigit()函数
  • 7 iscntrl()函数
  • 8 isgraph()函数
  • 9 isspace()函数
  • 10 isblank()函数
  • 11 isprint()函数
  • 12 ispunct()函数
  • 13 tolower()函数
  • 14 toupper()函数

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 isprint()函数

isprint()函数检测ch是否是可打印的,函数原型如下:

int isprint(int ch);

C语言标准描述如下:

1. Checks if the given character can be printed, i.e. it is either a number (0123456789), an uppercase letter (ABCDEFGHIJKLMNOPQRSTUVWXYZ), a lowercase letter (abcdefghijklmnopqrstuvwxyz), a punctuation character(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~), or space, or any character classified as printable by 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 can be printed, zero otherwise.

12 ispunct()函数

ispunct()函数检测ch是否是标点符号,函数原型如下:

int ispunct(int ch);

C语言标准描述如下:

1. Checks if the given character is a punctuation character in the current C locale. The default C locale classifies the characters !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ as punctuation.
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 punctuation character, zero otherwise.

13 tolower()函数

tolower()函数将大写字符转换为小写字母,函数原型如下:

int tolower( int ch );

C语言标准描述如下:

1. Converts the given character to lowercase according to the character conversion rules defined by the currently installed C locale.
2. In the default "C" locale, the following uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ are replaced with respective lowercase letters abcdefghijklmnopqrstuvwxyz.
3. Lowercase version of ch or unmodified ch if no lowercase version is listed in the current C locale.

14 toupper()函数

toupper()函数将小写字符转换为大写字母,函数原型如下:

int toupper( int ch );

C语言标准描述如下:

1. Converts the given character to lowercase according to the character conversion rules defined by the currently installed C locale.
2. In the default "C" locale, the following uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ are replaced with respective lowercase letters abcdefghijklmnopqrstuvwxyz.
3. Uppercase version of ch or unmodified ch if no uppercase version is listed in the current C locale.

http://www.kler.cn/a/146854.html

相关文章:

  • python高级之简单爬虫实现
  • 一文了解Android的核心系统服务
  • 设计模式-Adapter(适配器模式)GO语言版本
  • 探索 HTML 和 CSS 实现的 3D旋转相册
  • 【UGUI】背包的交互01(道具信息跟随鼠标+道具信息面板显示)
  • Django5 2024全栈开发指南(二):Django项目配置详解
  • 语音识别学习笔记
  • 【云备份】数据管理模块
  • 【MyBatisPlus】通俗易懂 快速入门 详细教程
  • 代码随想录算法训练营第五十七天|739. 每日温度、496.下一个更大元素 I
  • java学习part13Object类和常用方法
  • C#中的事件(委托的发布和订阅、事件的发布和订阅、EventHandler类、Windows事件)
  • scoop bucket qq脚本分析(qq绿色安装包制作)
  • UDP客户端使用connect与UDP服务器使用send函数和recv函数收发数据
  • 蚂蚁庄园小课堂答题今日答案最新
  • 【腾讯云云上实验室】用向量数据库—实践相亲社交应用
  • 数据结构 | TOP-K问题
  • Linux安装Tesseract-OCR(操作系统CentOS)
  • H3C网络管理系统任意文件读取漏洞复现 [附POC]
  • 线性分类器--图像表示
  • 网易云音频数据如何爬取?
  • 通俗易懂的spring Cloud;业务场景介绍 二、Spring Cloud核心组件:Eureka 、Feign、Ribbon、Hystrix、zuul
  • MATLAB中FFT频谱分析使用详解
  • Mysql之局域网内不同ip互登陆mysql
  • SpringBoot yml配置文件打印值
  • 【iOS-UIImagePickerController访问相机和相册】