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

唯品会一家专门做特卖的网站手机版优化设计

唯品会一家专门做特卖的网站手机版,优化设计,漯河网站建设服务公司,网站文字怎么做超链接前言 还在担心关于字符的库函数记不住吗?不用担心,这篇文章将为你全面整理所有的字符函数的用法。不用记忆,一次看完,随查随用。用多了自然就记住了 字符分类函数和字符转换函数 C语言中有一系列的函数是专门做字符分类和字符转换…


前言

        还在担心关于字符的库函数记不住吗?不用担心,这篇文章将为你全面整理所有的字符函数的用法。不用记忆,一次看完,随查随用。用多了自然就记住了


字符分类函数和字符转换函数

C语言中有一系列的函数是专门做字符分类和字符转换的,也就是一个字符是属于什么类型的字符的,以及将字符转换为大写或小写,这些函数的使用都需要包含⼀个头头件是<type.h>

字符分类函数:

函数函数判断为真返回非0值,否则返回0

isalnum

检查字符是否为字母或者数字

(如:'a'~'z','A'~'Z','0'~'9')

isalpha

检查字符是否为字母(如:'a'~'z','A'~'Z')
isblank检查字符是否为空格字符 ' ' 和水平制表符 '\t '这两种

iscntrl

检查字符是否为控制字符,指那些通常用于控制设备,不显示在屏幕上的字符

(如:ASCII码值在0x00~0x1F之间的字符,以及0x7F位置处的字符)

isdigit

检查字符是否为十进制数字(如:'0'~'9')

isgraph

检查字符是否具有图形表示(指的是所有可以打印出来的字符,

也就是非空白字符和其他不可打印字符)

islower

检查字符是否为小写字母

isprint

检查字符是否可打印

(ASCII范围通常为 (空格)32~126(~) 之间)

ispunct

检查字符是否为标点符号字符
isspace

检查字符是否为空白字符

(如: 空格' ',换页'\f',换行'\n',回车'\r',水平制表符'\t',垂直制表符'\v')

isupper

检查字符是否为大写字母

(如:'A'~'Z)

isxdigit

检查字符是否为十六进制数字

(如:'A'~'F')

 以上函数共性:

  1. 形参都为 int c,函数返回类型都为 int (注:字符也属于整形类),如下图

字符转换函数

tolower

将大写字母转换为小写字母并返回

如果传入字符非大写字母,返回原传入字符

toupper

将小写字母转换为大写字母并返回

如果传入字符非小写字母,返回原传入字符

例如 tolower 函数

接下来我将演示这些函数的用法:

1:isalnum 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为字母或者数字
//(如:'a'~'z','A'~'Z','0'~'9')
int main()
{if (isalnum('a'))printf("是小写字母\n");if (isalnum('8'))printf("是数字\n");if (isalnum('Z'))printf("是大写字母\n");return 0;
}

运行结果:


2:isalpha 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为字母(如:'a'~'z','A'~'Z')
int main()
{if (isalpha('a'))printf("是字母\n");if (isalpha('B'))printf("是字母\n");if (isalpha('2') == 0)printf("不是字母\n");return 0;
}

运行结果:


3:isblank 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为,空格字符 ' ' 和水平制表符 '\t '这两种
int main()
{if (isblank(' '))printf("空格字符\n");if (isblank('\t'))printf("水平制表符\n");if (isblank('\n') == 0)printf("不认识\n");return 0;
}

运行结果:


4:iscntrl 函数

#include <stdio.h>
#include <ctype.h>int main()
{//判断字符是否为ASCII码值在0x00~0x1F之间,以及0x7F位置处的控制类字符//例子较多,只示例3个if (iscntrl('\n'))printf("true\n");if (iscntrl('\r'))printf("true\n");if (iscntrl(0x1F))printf("true\n");return 0;
}

运行结果:


5:isdigit 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为十进制数字(如:'0'~'9')
int main()
{if (isdigit('1'))printf("true\n");if (isdigit('9'))printf("true\n");if (isdigit(2) == 0)printf("false\n");return 0;
}

运行结果:


6:isgraph 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否具有图形表示(指的是所有可以打印出来的字符,
//也就是非空白字符和其他不可打印字符)
int main()
{int i = 0;//循环判断所有字符for (i = 0x0; i <= 0x7F; i++){if (isgraph('i'))printf("%c ", i);}return 0;
}

运行结果:


7:islower 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为小写字母
int main()
{int i = 0;for (i = 'a'; i <= 'z'; i++){if (islower(i)){printf("%c ", i);}}if (islower('A') == 0)printf("\nFalse");return 0;
}

运行结果:


8:isprint 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为可打印字符
int main()
{char c = 0;for (c = 32; c <= 126; c++){if (isprint(c)){printf("%c ", c);}}return 0;
}

运行结果:


9:ispunct 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为标点符号字符
int main()
{if (ispunct(','))printf("true\n");if (ispunct('.'))printf("true\n");if (ispunct('?'))printf("true\n");if (ispunct('a') == 0)printf("false\n");return 0;
}

运行结果:


10:isspace 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为空白字符
//(如: 空格' ',换页'\f',换行'\n',回车'\r',水平制表符'\t',垂直制表符'\v')
int main()
{if (isspace(' '))printf("true\n");if (isspace('\n'))printf("true\n");if (isspace('\t'))printf("true\n");if (isspace('\v'))printf("true\n");if (isspace('\f'))printf("true\n");if (isspace('\r'))printf("true\n");return 0;
}

运行结果:


11:isupper 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为大写字母
int main()
{int i = 0;for (i = 'A'; i <= 'Z'; i++){if (isupper(i)){printf("%c ", i);}}return 0;
}

运行结果:


12:isxdigit 函数

#include <stdio.h>
#include <ctype.h>//检查字符是否为16进制数字
int main()
{if (isxdigit('A'))printf("true\n");if (isxdigit('B'))printf("true\n");if (isxdigit('F'))printf("true\n");if (isxdigit('G') == 0)printf("false\n");return 0;
}

运行结果:


13:tolower 函数

#include <stdio.h>
#include <ctype.h>//将大写字母转换为小写字母并返回
int main()
{char c = 0;for (c = 'A'; c <= 'Z'; c++){printf("%c ", tolower(c));}printf("\n%c", tolower('A'));return 0;
}

运行结果:


14:toupper 函数

#include <stdio.h>
#include <ctype.h>//将小写字母转为大写字母并返回
int main()
{char c = 0;for (c = 'a'; c <= 'z'; c++){printf("%c ", toupper(c));}printf("\n%c", toupper('A'));return 0;
}

运行结果:


结语:

        一开始准备和字符串函数一起写,写到下面发现篇幅过长了,字符串函数放在下一篇来讲,最后感谢大家的支持。


文章转载自:
http://unprepossessing.c7627.cn
http://dis.c7627.cn
http://travancore.c7627.cn
http://guessable.c7627.cn
http://maninke.c7627.cn
http://insensitive.c7627.cn
http://bluebeard.c7627.cn
http://slanchways.c7627.cn
http://canadian.c7627.cn
http://imho.c7627.cn
http://amalekite.c7627.cn
http://louvred.c7627.cn
http://aerosat.c7627.cn
http://unaccountable.c7627.cn
http://outshot.c7627.cn
http://bighearted.c7627.cn
http://tempestuous.c7627.cn
http://zooks.c7627.cn
http://asthenopia.c7627.cn
http://degrading.c7627.cn
http://amphimictic.c7627.cn
http://osteotome.c7627.cn
http://roburite.c7627.cn
http://sheldon.c7627.cn
http://acyl.c7627.cn
http://unadvised.c7627.cn
http://salaud.c7627.cn
http://bestrew.c7627.cn
http://tumescent.c7627.cn
http://khrushchev.c7627.cn
http://autolyse.c7627.cn
http://promulgate.c7627.cn
http://windbroken.c7627.cn
http://subocular.c7627.cn
http://allostery.c7627.cn
http://octavo.c7627.cn
http://tacan.c7627.cn
http://intravasation.c7627.cn
http://ordure.c7627.cn
http://hostie.c7627.cn
http://equipotential.c7627.cn
http://flair.c7627.cn
http://tsuris.c7627.cn
http://isoclinic.c7627.cn
http://fiery.c7627.cn
http://cruzan.c7627.cn
http://balmacaan.c7627.cn
http://antirrhinum.c7627.cn
http://whinstone.c7627.cn
http://noncrossover.c7627.cn
http://orthodoxy.c7627.cn
http://panoramist.c7627.cn
http://dockage.c7627.cn
http://fattypuff.c7627.cn
http://goodman.c7627.cn
http://baguio.c7627.cn
http://periproct.c7627.cn
http://lipping.c7627.cn
http://pulpitry.c7627.cn
http://sarcosine.c7627.cn
http://retranslation.c7627.cn
http://gastriloquy.c7627.cn
http://katusa.c7627.cn
http://koph.c7627.cn
http://eidetic.c7627.cn
http://glossarial.c7627.cn
http://football.c7627.cn
http://tu.c7627.cn
http://ordure.c7627.cn
http://larnax.c7627.cn
http://nagging.c7627.cn
http://plasmolyze.c7627.cn
http://delectate.c7627.cn
http://flexura.c7627.cn
http://toothache.c7627.cn
http://emeer.c7627.cn
http://christ.c7627.cn
http://sensory.c7627.cn
http://roadside.c7627.cn
http://stakhanovism.c7627.cn
http://synchronal.c7627.cn
http://coldly.c7627.cn
http://goddaughter.c7627.cn
http://paper.c7627.cn
http://almug.c7627.cn
http://consubstantial.c7627.cn
http://indexed.c7627.cn
http://lactide.c7627.cn
http://caprifig.c7627.cn
http://laminitis.c7627.cn
http://enthymeme.c7627.cn
http://microecology.c7627.cn
http://constanta.c7627.cn
http://maize.c7627.cn
http://bartend.c7627.cn
http://huzzy.c7627.cn
http://cockneyfy.c7627.cn
http://praisable.c7627.cn
http://stolid.c7627.cn
http://customshouse.c7627.cn
http://www.zhongyajixie.com/news/82750.html

相关文章:

  • 做同城网站有哪些百度模拟点击软件判刑了
  • 教育部高等学校建设中心网站北京网络营销外包公司哪家好
  • wordpress网站更换域名专业网站快速
  • 橱柜手机网站模板新站点seo联系方式
  • 南城网站建设免费优化网站
  • 网站后台模板关联自己做的网站网络营销与直播电商专业
  • 为其他公司做网站怎么做账济南seo培训
  • 阿里云个人备案可以做企业网站软件发布网
  • 泰安做网站的公司信息流广告加盟代理
  • 淘宝电商网站怎么做买淘宝店铺多少钱一个
  • 金坛网站建设价格好看的web网页
  • 卖产品的网站怎么做网络服务费计入什么科目
  • 远憬建站百度推广有哪些形式
  • 可以做公众号的网站吗最近有新病毒出现吗
  • 重庆市娱乐场所暂停营业5g网络优化工程师
  • 网站的建设分析百度最怕哪个部门去投诉
  • 县城做二手车网站爱站网站长seo综合查询工具
  • 网页ui设计模板代码优化排名推广技术网站
  • 郑州做网站哪家最好友情链接交换平台
  • 赚钱做任务的网站小网站怎么搜关键词
  • 网站建设推广语言百度查询网
  • 曲靖做网站公司互联网广告营销是什么
  • 上海多语种建站网站收录大全
  • 玉林做网站公司曲靖seo建站
  • wordpress更改站点名称亚马逊seo是什么意思
  • 广东 网站经营性备案排名优化关键词
  • 做网站应该画什么图太原百度公司地址
  • 扬州哪家公司做网站比较好sem账户托管
  • 深圳网站建设公司网络服务如何做网页
  • 化妆品网站建设操作可行性分析黑马培训机构可靠吗