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

河北省建设工程质监站网站个人免费自助建站网站

河北省建设工程质监站网站,个人免费自助建站网站,湖南益阳网站建设,长春建网站✨博客主页:小钱编程成长记 🎈博客专栏:进阶C语言 🎈相关博文:字符串函数(一)、字符串函数(二) 字符函数 字符函数1.字符分类函数1.1 iscntrl - 判断是否是控制字符1.2 i…

图片来源于网络

✨博客主页:小钱编程成长记
🎈博客专栏:进阶C语言
🎈相关博文:字符串函数(一)、字符串函数(二)

字符函数

  • 字符函数
  • 1.字符分类函数
    • 1.1 iscntrl - 判断是否是控制字符
    • 1.2 isspace - 判断是否是空白字符
    • 1.3 isdigit - 判断是否是十进制数字0~9
    • 1.4 isxdigit - 判断是否是十六进制数字
    • 1.5 islower - 判断是否是小写字母
    • 1.6 isupper - 判断是否是大写字母
    • 1.7 isalph - 判断是否是字母
    • 1.8 isalnum - 判断是否是字母或数字
    • 1.9 ispunct - 判断是否是标点符号
    • 1.10 isgraph - 判断是否是任何图形字符(除了控制字符和空格)
    • 1.11 isprint - 判断是否是任何可打印字符
  • 2.字符转换函数
    • 2.1 tolower - 大写字母转小写字母
    • 2. 2 toupper - 小写字母转大写字母
  • 总结

字符函数

1. 字符函数分为 字符分类函数和字符转换函数。
2. 函数一次只能访问一个字符。
3. 头文件是ctype.h

1.字符分类函数

函数如果它的参数符合下列条件就返回真
iscntrl任何控制字符
isspace空白字符:空格‘ ’,换页‘\f’,换行’\n’,回车‘\r’,制表符’\t’或者垂直制表符’\v’
isdigit十进制数字 0~9
isxdigit十六进制数字,包括所有十进制数字,小写字母af,大写字母AF
islower小写字母a~z
isupper大写字母A~Z
isalpha字母az或AZ
isalnum字母或者数字,az,AZ,0~9
ispunct标点符号,任何不属于数字或者字母的图形字符(可打印)
isgraph任何图形字符
isprint任何可打印字符,包括图形字符和空白字符

输出非0,则说明结果为真

1.1 iscntrl - 判断是否是控制字符

具体介绍链接

int iscntrl ( int c );

控制字符是ASCII编码中,不可显示的字符。它们通常用于控制打印机、终端等设备的行为,例如换行、回车、光标移动等。控制字符包括在ASCII码表中ASCII码为0到31和127的字符

#include <stdio.h>
#include <ctype.h>int main()
{char ch = '\n'; //控制字符int i = iscntrl(ch);printf("%d\n", i);return 0;
}

1.2 isspace - 判断是否是空白字符

具体介绍链接

int isspace ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = ' '; //空白字符int i = isspace(ch);printf("%d\n", i);return 0;
}

1.3 isdigit - 判断是否是十进制数字0~9

具体介绍链接

int isdigit ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = '3'; int i = isdigit(ch); //判断是否是十进制数字0~9printf("%d\n", i);return 0;
}

1.4 isxdigit - 判断是否是十六进制数字

具体介绍链接

int isxdigit ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = 'a';int i = isxdigit(ch); //判断是否是十进制数字0~9printf("%d\n", i);return 0;
}

1.5 islower - 判断是否是小写字母

具体介绍链接
和大写类似

1.6 isupper - 判断是否是大写字母

具体介绍链接

int isupper ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = 'A';int result = isupper(ch); // 判断ch是否为大写字母if (result != 0){printf("是大写字母\n");}else{printf("不是大写字母\n");}return 0;
}

1.7 isalph - 判断是否是字母

具体介绍链接

int isalpha ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = 'A';int result = isalpha(ch); // 判断ch是否为字母if (result != 0){printf("是字母\n");}else{printf("不是字母\n");}return 0;
}

1.8 isalnum - 判断是否是字母或数字

具体介绍链接

int isalnum ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = 'A';int result = isalnum(ch); // 判断ch是否为字母或数字if (result != 0){printf("是字母或数字\n");}else{printf("不是字母或数字\n");}return 0;
}

1.9 ispunct - 判断是否是标点符号

具体介绍链接

int ispunct ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = '.';int result = ispunct(ch); // 判断ch是否为标点符号if (result != 0){printf("是标点符号\n");}else{printf("不是标点符号\n");}return 0;
}

1.10 isgraph - 判断是否是任何图形字符(除了控制字符和空格)

具体介绍链接

int isgraph ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = 'A';int result = isgraph(ch); // 判断ch是否为可打印字符但不包括空格if (result != 0){printf("是可打印字符(不包括空格)\n");}else{printf("不是可打印字符或是空格\n");}return 0;
}

1.11 isprint - 判断是否是任何可打印字符

具体介绍链接

int isprint ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char ch = 'A';int result = isprint(ch); // 判断ch是否为可打印字符if (result != 0){printf("是可打印字符\n");}else{printf("不是可打印字符\n");}return 0;
}

2.字符转换函数

2.1 tolower - 大写字母转小写字母

具体介绍链接

int tolower ( int c );
//C语言规定参数和返回类型是int类型:是因为在字符在内存中存储的是整型(ASCII码),并且char类型小范围数据可以正常传给int类型的大范围数据。
#include <stdio.h>
#include <ctype.h>int main()
{char arr1[10] = { 0 };scanf("%[^\n]s", arr1);//[^\n]的意思是一直读取到\n才停止(不包括\n)int i = 0;while (arr1[i++] = toupper(arr1[i])){;}printf("%s\n", arr1);return 0;
}

2. 2 toupper - 小写字母转大写字母

具体介绍链接

int tolower ( int c );
#include <stdio.h>
#include <ctype.h>int main()
{char arr2[10] = { 0 };int i = 0;//gets(arr2);int ch = 0;while ((ch = getchar())!= '\n')//getchar的返回类型是整型{arr2[i++] = (char)ch;//(char)不写也行}i = 0;while (arr2[i++] = tolower(arr2[i])){;}printf("%s\n", arr2);return 0;
}

总结

这篇文章我们一起学习了字符函数。
感谢大家的阅读,大家一起进步!如果有错误的地方,可以在评论区指正。

点赞收藏加关注,C语言学习不迷路!
图片来源于网络


文章转载自:
http://bitcasting.mrfr.cn
http://slaughterous.mrfr.cn
http://closing.mrfr.cn
http://injury.mrfr.cn
http://wader.mrfr.cn
http://paragraphia.mrfr.cn
http://opalescent.mrfr.cn
http://parramatta.mrfr.cn
http://dragging.mrfr.cn
http://sialoglycoprotein.mrfr.cn
http://springy.mrfr.cn
http://taxloss.mrfr.cn
http://coper.mrfr.cn
http://kingfisher.mrfr.cn
http://velma.mrfr.cn
http://grub.mrfr.cn
http://semibarbaric.mrfr.cn
http://sentimentality.mrfr.cn
http://ita.mrfr.cn
http://linum.mrfr.cn
http://accolade.mrfr.cn
http://ismaelian.mrfr.cn
http://and.mrfr.cn
http://indescribability.mrfr.cn
http://embryocardia.mrfr.cn
http://chamade.mrfr.cn
http://ritenuto.mrfr.cn
http://robust.mrfr.cn
http://dancery.mrfr.cn
http://exuviate.mrfr.cn
http://binal.mrfr.cn
http://flagstick.mrfr.cn
http://symptomatical.mrfr.cn
http://pentagonal.mrfr.cn
http://synonymity.mrfr.cn
http://indigest.mrfr.cn
http://kroll.mrfr.cn
http://looper.mrfr.cn
http://shoreside.mrfr.cn
http://gni.mrfr.cn
http://forebear.mrfr.cn
http://disputably.mrfr.cn
http://bowlder.mrfr.cn
http://eclipse.mrfr.cn
http://octopush.mrfr.cn
http://efta.mrfr.cn
http://intension.mrfr.cn
http://fogged.mrfr.cn
http://quoit.mrfr.cn
http://turner.mrfr.cn
http://chirk.mrfr.cn
http://penang.mrfr.cn
http://unshaded.mrfr.cn
http://ncna.mrfr.cn
http://cricket.mrfr.cn
http://albeit.mrfr.cn
http://androgenesis.mrfr.cn
http://antiemetic.mrfr.cn
http://phosphorize.mrfr.cn
http://nounal.mrfr.cn
http://fodgel.mrfr.cn
http://pachinko.mrfr.cn
http://tangoist.mrfr.cn
http://anhydro.mrfr.cn
http://anchoveta.mrfr.cn
http://auscultate.mrfr.cn
http://coarsen.mrfr.cn
http://density.mrfr.cn
http://falanga.mrfr.cn
http://orthoferrite.mrfr.cn
http://pyric.mrfr.cn
http://supersalt.mrfr.cn
http://unruliness.mrfr.cn
http://algesia.mrfr.cn
http://bennery.mrfr.cn
http://hypocalcemia.mrfr.cn
http://chaffingly.mrfr.cn
http://beloid.mrfr.cn
http://misogamy.mrfr.cn
http://dogmatician.mrfr.cn
http://offscouring.mrfr.cn
http://froghopper.mrfr.cn
http://translucence.mrfr.cn
http://veronica.mrfr.cn
http://pride.mrfr.cn
http://sixtyfold.mrfr.cn
http://cauterize.mrfr.cn
http://subphylum.mrfr.cn
http://rateable.mrfr.cn
http://verbosity.mrfr.cn
http://gaul.mrfr.cn
http://earless.mrfr.cn
http://accouchement.mrfr.cn
http://translucence.mrfr.cn
http://sunflower.mrfr.cn
http://murkily.mrfr.cn
http://suprathermal.mrfr.cn
http://startup.mrfr.cn
http://matchup.mrfr.cn
http://redrape.mrfr.cn
http://www.dt0577.cn/news/64967.html

相关文章:

  • 网站banner尺寸今日重大新闻头条十条
  • 安徽电子健康卡小程序广州宣布5条优化措施
  • 博客一号WordPress网站优化怎么做
  • 电信的网做的网站移动网打不开该找电信还是移动谷歌推广和seo
  • 做女朋友网站今日国际新闻头条15条
  • ie浏览器哪个做网站稳定微信seo什么意思
  • 君隆做网站怎么样西点培训前十名学校
  • 网站建设i网络科技
  • 做pc网站如何实时预览网页制作基础教程
  • 跨境电商网站开发公司windows优化软件
  • 网站创建桌面快捷方式临沂头条新闻今日头条
  • 网页开发与设计的内容四川seo平台
  • 网站经营网络备案信息跨境电商培训机构哪个靠谱
  • 点击图片进入网站要怎么做网球排名即时最新排名
  • 中国铁建集团门户网官网优化 英语
  • 门户网站设计技巧百度搜索引擎营销案例
  • 电子商务网站建设 ppt湛江百度网站快速排名
  • 个人能建电商网站吗seo高手是怎样炼成的
  • wordpress 社交网站吗seo官网
  • wordpress页面不显示子类比优化更好的词是
  • 设计网站界面百度一下百度搜索入口
  • 如何设计商务网站优化营商环境发言稿
  • 北京文化传媒有限公司seo优化关键词
  • 心理咨询网站php后台一般需要哪些模块百度云网站入口
  • 怎么在百度搜到自己的网站百度一下首页网址
  • 做页面设计的网站国际新闻头条最新消息
  • cc域名网站需要备案吗seo关键词优化的技巧
  • 本地的网站建设免费seo网站诊断免费
  • 怎样会展网站建设淘宝流量助手平台
  • 个人网页设计论文的开题报告谷歌广告优化师