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

【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.

相关文章:

【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()函数…...

极兔快递查询,极兔快递单号查询,对需要的单号记录进行备注

批量查询极兔快递单号的物流信息&#xff0c;对需要的快递单号记录进行备注。 所需工具&#xff1a; 一个【快递批量查询高手】软件 极兔快递单号若干 操作步骤&#xff1a; 步骤1&#xff1a;运行【快递批量查询高手】软件&#xff0c;并登录 步骤2&#xff1a;点击主界面左…...

树的序列化与反序列化

1 序列化与反序列化 二叉树的序列化与反序列化 1.1 实现思路 方式一&#xff1a;前序遍历 通过前序遍历方式实现二叉树的序列化将结果存入队列中要注意空节点也要存null 方式二&#xff1a;层序遍历 层序遍历也是用队列实现注意从左到右&#xff0c;遇到空节点存null 1.2 …...

定长子网划分和变长子网划分问题_二叉树解法_通俗易懂_配考研真题

引入:定长子网划分和变长子网划分的基本概念 定长子网划分和变长子网划分的基本概念 目前常用的子网划分&#xff0c;是基于CIDR的子网划分&#xff0c;也就是将给定的CIDR地址块划分为若干个较小的CIDR地址块。 定长子网划分: 使用同一个子网掩码来划分子网&#xff0c;因…...

ruoyi 前后分离部署502

ruoyi 前后分离部署502 我使用了nginx部署前端&#xff0c;使用docker部署。nginx文件如下&#xff1a; server {listen 8086; #设置端口listen [::]:8086; #设置端口server_name localhost;#access_log /var/log/nginx/host.access.log main;location / {root /…...

【Python】多年数据分成不同sheet

需求&#xff1a; excel文件中包含多年数据&#xff0c;其中一列列名为“年”&#xff0c;要保存一个新excel&#xff0c;将年数值不同的行保存在不同的sheet文件中&#xff0c;每个sheet文件第一行仍为原数据第一行&#xff0c;并且每个sheet名为对应的年的值。 拆分年份数据…...

Cache学习(3):Cache地址映射(直接映射缓存组相连缓存全相连缓存)

1 Cache的与存储地址的映射 以一个Cache Size 为 128 Bytes 并且Cache Line是 16 Bytes的Cache为例。首先把这个Cache想象成一个数组&#xff0c;数组总共8个元素&#xff0c;每个元素大小是 16 Bytes&#xff0c;如下图&#xff1a; 现在考虑一个问题&#xff0c;CPU从0x0654…...

GIT | 基础操作 | 初始化 | 添加文件 | 修改文件 | 版本回退 | 撤销修改 | 删除文件

GIT | 基础操作 | 初始化 | 添加文件 | 修改文件 | 版本回退 | 撤销修改 | 删除文件 文章目录 GIT | 基础操作 | 初始化 | 添加文件 | 修改文件 | 版本回退 | 撤销修改 | 删除文件前言一、安装git二、git基本操作2.1 初始化git2.2 配置局部生效2.3 配置全局生效 三、认识工作区…...

HCIA-RS基础-距离矢量路由协议

前言&#xff1a; 动态路由协议根据寻径方式可以分为距离矢量路由协议和链路状态路由协议。本文将详细介绍距离矢量路由协议的原理&#xff0c;并阐述其中一个重要概念——路由环路&#xff0c;同时介绍如何避免路由环路的方法。通过学习本文&#xff0c;您将能够深入理解距离矢…...

Python与设计模式--简单工厂模式

2-Python与设计模式–简单工厂模式 一、快餐点餐系统 想必大家一定见过类似于麦当劳自助点餐台一类的点餐系统吧。在一个大的触摸显示屏上&#xff0c;有三类可以选择的上餐品&#xff1a; 汉堡等主餐、小食、饮料。当我们选择好自己需要的食物&#xff0c;支付完成后&#x…...

四、防火墙-NAT Server

学习防火墙之前&#xff0c;对路由交换应要有一定的认识 NAT Server1.1.基本原理1.2.多出口场景下的NAT Server1.3.源进源出 —————————————————————————————————————————————————— NAT Server 一般对用户提供一些可访问的…...

Rust - cargo项目里多个二进制binary crate的编译运行

目录 foo - Cargo.toml - src - - main.rs - - bin - - - other-bin.rs将除默认入口文件外待作为二进制crate处理的文件放在src/bin目录下 方法一&#xff1a; 命令行增加配置项 --bin xxx cargo run --bin foo // 注意! 这里是包名&#xff0c;不是main cargo run --bin o…...

python爬虫教程:selenium常用API用法和浏览器控制

文章目录 selenium apiwebdriver常用APIwebelement常用API 控制浏览器 selenium api selenium新版本(4.8.2)很多函数&#xff0c;包括元素定位、很多API方法均发生变化&#xff0c;本文记录以selenium4.8.2为准。 webdriver常用API 方法描述get(String url)访问目标url地址&…...

2024年天津天狮学院专升本食品质量与安全专业《分析化学》考纲

2024年天津天狮学院食品质量与安全专业高职升本入学考试《分析化学》考试大纲 一、考试性质 《分析化学》专业课程考试是天津天狮学院食品质量与安全专业高职升本入学考试 的必考科目之一&#xff0c;其性质是考核学生是否达到了升入本科继续学习的要求而进行的选拔性考试。《…...

2023年亚太地区数学建模大赛 C 题

我国新能源电动汽车的发展趋势 新能源汽车是指以先进技术原理、新技术、新结构的非常规汽车燃料为动力来源&#xff08;非常规汽车燃料指汽油、柴油以外的燃料&#xff09;&#xff0c;将先进技术进行汽车动力控制和驱动相结合的汽车。新能源汽车主要包括四种类型&#xff1a;…...

TDlib readme

不同开发语言使用TDlib的连接入口&#xff1a;td/example/README.md at master tdlib/td (github.com) 如golang:td/example/README.md at master tdlib/td (github.com)...

紧急救援【Dijkstra】

作为一个城市的应急救援队伍的负责人&#xff0c;你有一张特殊的全国地图。在地图上显示有多个分散的城市和一些连接城市的快速道路。每个城市的救援队数量和每一条连接两个城市的快速道路长度都标在地图上。当其他城市有紧急求助电话给你的时候&#xff0c;你的任务是带领你的…...

「Verilog学习笔记」数据累加输出

专栏前言 本专栏的内容主要是记录本人学习Verilog过程中的一些知识点&#xff0c;刷题网站用的是牛客网 在data_out准备好&#xff0c;valid_b拉高时&#xff0c;如果下游的ready_b为低&#xff0c;表示下游此时不能接收本模块的数据&#xff0c;那么&#xff0c;将会拉低ready…...

typeof,instanceof

1.typeof typeof运算符返回的结果是以小写的字符串表示的变量的类型 2.instanceof instanceof运算符用于判断右边构造函数的原型对象是否在左边对象的原型链上 let arr[]let obj{}let datenew Dateconsole.log(arr instanceof Array)console.log(arr instanceof Object)conso…...

传统数仓和clickhouse对比

背景 传统数仓一般都是HiveSparkSql作为代表&#xff0c;不过也包括Kylin等&#xff0c;而clickhouse是实时OLAP的代表&#xff0c;我们简单看下他们的对比 传统数仓和clickhouse对比 HiveSparkSQL的传统数仓&#xff1a; 1.数据更新速度慢&#xff0c;由于传统数仓一般都是…...

别再只优化模型!AIAgent架构成本优化的终极盲区:状态管理、重试策略与超时熔断的协同降本公式

第一章&#xff1a;AIAgent架构成本优化的认知升维&#xff1a;从模型层到系统层的范式转移 2026奇点智能技术大会(https://ml-summit.org) 传统AI工程实践常将成本优化锚定在模型参数量、推理延迟或GPU显存占用等单一维度&#xff0c;但AIAgent的复杂性源于其多模块协同——…...

OpenSpec实战:从规范到代码的AI驱动开发工作流

1. OpenSpec实战&#xff1a;为什么我们需要规范驱动的开发 在传统开发流程中&#xff0c;最让人头疼的问题莫过于"代码写完了&#xff0c;但和需求文档对不上"。我见过太多项目在交付时才发现&#xff0c;开发人员理解的"用户登录功能"和产品经理描述的完…...

艾尔登法环存档迁移终极指南:告别存档丢失的完整解决方案

艾尔登法环存档迁移终极指南&#xff1a;告别存档丢失的完整解决方案 【免费下载链接】EldenRingSaveCopier 项目地址: https://gitcode.com/gh_mirrors/el/EldenRingSaveCopier 在交界地的冒险中&#xff0c;最令人绝望的莫过于数百小时的游戏进度因存档损坏而瞬间消失…...

语音指令分类模型训练(基于机器学习方法)

1、统计音频长度信息&#xff0c;便于后续参数的设定import os import librosa import numpy as np# 配置参数 DATA_PATH "data4c" # 数据集根目录 FIXED_SAMPLE_RATE 16000def stat_audio_lengths():# 存储所有音频的长度&#xff08;采样点数&#xff09;和时长…...

基于EMD经验模态分解的数据分解方法 Matlab语言 1.不用工具箱,自带函数,无需调整分量个数自行出图,可用作信号分解等问题,也可用作对比方法。包括原始信号图、分解效果图、频谱图,~ 2.直接替换

基于EMD经验模态分解的数据分解方法 Matlab语言 1.不用工具箱&#xff0c;自带函数&#xff0c;无需调整分量个数自行出图&#xff0c;可用作信号分解等问题&#xff0c;也可用作对比方法。包括原始信号图、分解效果图、频谱图&#xff0c;&#xff5e; 2.直接替换Excel数据即可…...

5分钟精通百度网盘提取码智能获取:baidupankey完全使用指南

5分钟精通百度网盘提取码智能获取&#xff1a;baidupankey完全使用指南 【免费下载链接】baidupankey 项目地址: https://gitcode.com/gh_mirrors/ba/baidupankey 还在为百度网盘分享链接的提取码而烦恼吗&#xff1f;每次遇到需要密码的资源都要四处搜索&#xff0c;浪…...

STM32H7 GPIO实战:用CubeMX和STM32CubeProgrammer实现LED闪烁(避坑指南)

STM32H7 GPIO实战&#xff1a;用CubeMX和STM32CubeProgrammer实现LED闪烁&#xff08;避坑指南&#xff09; 在嵌入式开发领域&#xff0c;STM32H7系列以其高性能和丰富的外设资源受到开发者青睐。GPIO作为最基础也最常用的外设之一&#xff0c;看似简单却暗藏玄机。本文将带您…...

注意力机制模块:顶会 CVPR 2025 最新注意力:Focused Linear Attention 替换传统 Softmax 注意力

⚠️ 重要声明:本文部分核心理论内容(Focused Linear Attention的聚焦映射函数和秩恢复模块)源自清华大学黄高老师团队于ICCV 2023发表的论文 FLatten Transformer: Vision Transformer using Focused Linear Attention(论文链接:https://arxiv.org/pdf/2308.00442,代码:…...

Llama-3.2-3B新手入门:用Ollama一键搭建你的本地AI助手

Llama-3.2-3B新手入门&#xff1a;用Ollama一键搭建你的本地AI助手 1. 为什么选择Llama-3.2-3B和Ollama组合 1.1 轻量级但实用的AI助手 Llama-3.2-3B是Meta最新推出的30亿参数语言模型&#xff0c;专为日常对话和多语言理解优化。相比其他同规模模型&#xff0c;它有三个突出…...

千问3.5-9B系统盘清理助手:智能分析C盘空间与生成清理方案

千问3.5-9B系统盘清理助手&#xff1a;智能分析C盘空间与生成清理方案 1. 引言&#xff1a;C盘爆满的烦恼与智能解决方案 电脑用久了&#xff0c;C盘变红几乎是每个Windows用户都会遇到的烦恼。系统运行变慢、软件无法更新、甚至蓝屏死机都可能与C盘空间不足有关。传统的手动…...