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

iis应用程序池 网站360推广登录入口官网

iis应用程序池 网站,360推广登录入口官网,手机网站开发成本,wordpress伪静态301错误文章目录 一、字符函数的构成二、字符函数的分类1、字符分类函数1、isalnum函数2、isalpha函数3、isdigit函数4、islower函数5、isupper函数6、ispunct函数7、isspace函数8、iscntrl函数9、isxdigit函数10、isgraph函数11、isprint函数 2、字符转换函数 三、字符函数的应用 一、…

文章目录

  • 一、字符函数的构成
  • 二、字符函数的分类
    • 1、字符分类函数
      • 1、`isalnum`函数
      • 2、`isalpha`函数
      • 3、`isdigit`函数
      • 4、`islower`函数
      • 5、`isupper`函数
      • 6、`ispunct`函数
      • 7、`isspace`函数
      • 8、`iscntrl`函数
      • 9、`isxdigit`函数
      • 10、`isgraph`函数
      • 11、`isprint`函数
    • 2、字符转换函数
  • 三、字符函数的应用

一、字符函数的构成

  • 头文件包含:在C语言中,许多字符函数都需要包含<ctype.h>头文件。这个头文件包含了一系列用于处理字符的函数原型声明。例如,#include <ctype.h>是使用字符函数的常见开头步骤。
  • 函数参数和返回值:字符函数通常以单个字符作为参数,返回值根据函数的功能而定。例如,int isalpha(int c)函数接受一个整数参数c(实际上是一个字符的ASCII码值),如果c是一个字母(大写或小写),则返回一个非零值(真),否则返回0(假)。

二、字符函数的分类

1、字符分类函数

1、isalnum函数

  • 作用:用于判断一个字符是否为字母或数字。字母包括大写字母(A - Z)和小写字母(a - z),数字是0 - 9
  • 函数原型int isalnum(int c);,其中c是要测试的字符(以ASCII码值的形式传递)。
  • 返回值:如果c是字母或数字,返回非零值(在C语言中,非零值表示真);如果c不是字母或数字,返回0(表示假)。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = 'A';char ch2 = '7';char ch3 = '$';if (isalnum(ch1)){printf("%c是字母或数字\n", ch1);}if (isalnum(ch2)){printf("%c是字母或数字\n", ch2);}if (!isalnum(ch3)){printf("%c不是字母或数字\n", ch3);}return 0;
    }
    
    输出结果为:
    A是字母或数字
    7是字母或数字
    $不是字母或数字
    

2、isalpha函数

  • 作用:专门用于判断一个字符是否为字母,包括大写字母(A - Z)和小写字母(a - z)。
  • 函数原型int isalpha(int c);
  • 返回值:如果c是字母,返回非零值;如果c不是字母,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = 'b';char ch2 = '9';if (isalpha(ch1)){printf("%c是字母\n", ch1);}if (!isalpha(ch2)){printf("%c不是字母\n", ch2);}return 0;
    }
    
    输出结果为:
    b是字母
    9不是字母
    

3、isdigit函数

  • 作用:判断一个字符是否为数字,即0 - 9
  • 函数原型int isdigit(int c);
  • 返回值:如果c是数字,返回非零值;如果c不是数字,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = '4';char ch2 = 'a';if (isdigit(ch1)){printf("%c是数字\n", ch1);}if (!isdigit(ch2)){printf("%c不是数字\n", ch2);}return 0;
    }
    
    输出结果为:
    4是数字
    a不是数字
    

4、islower函数

  • 作用:用于判断一个字符是否为小写字母,范围是a - z
  • 函数原型int islower(int c);
  • 返回值:如果c是小写字母,返回非零值;如果c不是小写字母,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = 'm';char ch2 = 'N';if (islower(ch1)){printf("%c是小写字母\n", ch1);}if (!islower(ch2)){printf("%c不是小写字母\n", ch2);}return 0;
    }
    
    输出结果为:
    m是小写字母
    N不是小写字母
    

5、isupper函数

  • 作用:判断一个字符是否为大写字母,范围是A - Z
  • 函数原型int isupper(int c);
  • 返回值:如果c是大写字母,返回非零值;如果c不是大写字母,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = 'Q';char ch2 = 'r';if (isupper(ch1)){printf("%c是大写字母\n", ch1);}if (!isupper(ch2)){printf("%c不是大写字母\n", ch2);}return 0;
    }
    
    输出结果为:
    Q是大写字母
    r不是大写字母
    

6、ispunct函数

  • 作用:用于判断一个字符是否为标点符号。标点符号包括各种非字母数字且有特定语法功能的字符,如!@#$%^&*()-+={}[]:;'"<>?/|\~等。
  • 函数原型int ispunct(int c);
  • 返回值:如果c是标点符号,返回非零值;如果c不是标点符号,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = ';';char ch2 = 'A';if (ispunct(ch1)){printf("%c是标点符号\n", ch1);}if (!ispunct(ch2)){printf("%c不是标点符号\n", ch2);}return 0;
    }
    
    输出结果为:
    ;是标点符号
    A不是标点符号
    

7、isspace函数

  • 作用:判断一个字符是否为空白字符。空白字符包括空格(' ')、制表符('\t')、换行符('\n')、回车符('\r')、垂直制表符('\v')和换页符('\f')。
  • 函数原型int isspace(int c);
  • 返回值:如果c是空白字符,返回非零值;如果c不是空白字符,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = '\n';char ch2 = 'a';if (isspace(ch1)){printf("%c是空白字符\n", ch1);}if (!isspace(ch2)){printf("%c不是空白字符\n", ch2);}return 0;
    }
    
    输出结果为:
    是空白字符
    a不是空白字符
    

8、iscntrl函数

  • 作用:用于判断一个字符是否为控制字符。控制字符是ASCII码值在0 - 31和127的字符,这些字符主要用于控制设备(如打印机、终端等)执行特定的操作,例如换行(\n)、回车(\r)等也属于控制字符,但要注意空格(' ')不是控制字符。
  • 函数原型int iscntrl(int c);,这里c是要测试的字符(以ASCII码值的形式传递)。
  • 返回值:如果c是控制字符,返回非零值;如果c不是控制字符,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = '\n';char ch2 = 'A';if (iscntrl(ch1)){printf("%c是控制字符\n", ch1);}if (!iscntrl(ch2)){printf("%c不是控制字符\n", ch2);}return 0;
    }
    
    输出结果为:
    是控制字符
    A不是控制字符
    

9、isxdigit函数

  • 作用:判断一个字符是否为十六进制数字字符。十六进制数字包括0 - 9、A - F(或a - f)。
  • 函数原型int isxdigit(int c);
  • 返回值:如果c是十六进制数字字符,返回非零值;如果c不是十六进制数字字符,返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = 'F';char ch2 = 'G';if (isxdigit(ch1)){printf("%c是十六进制数字字符\n", ch1);}if (!isxdigit(ch2)){printf("%c不是十六进制数字字符\n", ch2);}return 0;
    }
    
    输出结果为:
    F是十六进制数字字符
    G不是十六进制数字字符
    

10、isgraph函数

  • 作用:用于判断一个字符是否为可打印字符(除空格外)。可打印字符的ASCII码值范围通常是33 - 126。
  • 函数原型int isgraph(int c);
  • 返回值:如果c是可打印字符(非空格),返回非零值;如果c不是可打印字符(非空格),返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = '!';char ch2 = ' ';if (isgraph(ch1)){printf("%c是可打印字符(非空格)\n", ch1);}if (!isgraph(ch2)){printf("%c不是可打印字符(非空格)\n", ch2);}return 0;
    }
    

输出结果为:

 ```
!是可打印字符(非空格)不是可打印字符(非空格)```

11、isprint函数

  • 作用:判断一个字符是否为可打印字符,包括空格。可打印字符的ASCII码值范围通常是32 - 126。
  • 函数原型int isprint(int c);
  • 返回值:如果c是可打印字符(包括空格),返回非零值;如果c不是可打印字符(包括空格),返回0。
  • 示例代码
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {char ch1 = ' ';char ch2 = '\n';if (isprint(ch1)){printf("%c是可打印字符(包括空格)\n", ch1);}if (!isprint(ch2)){printf("%c不是可打印字符(包括空格)\n", ch2);}return 0;
    }
    
    输出结果为:
    是可打印字符(包括空格)
    不是可打印字符(包括空格)
    

2、字符转换函数

 - **功能**:将字符从一种形式转换为另一种形式。- **举例**:- `tolower(c)`:将大写字母`c`转换为小写字母。如果`c`不是大写字母,则返回`c`本身。- 例如,`char ch = 'A'; ch = tolower(ch);`之后,`ch`的值变为`'a'`。- `toupper(c)`:与`tolower`相反,将小写字母转换为大写字母。- 例如,`char ch = 'b'; ch = toupper(ch);`后,`ch`的值变为`'B'`。

三、字符函数的应用

  • 数据验证

    • 举例:在用户输入密码的程序中,可以使用isdigitisalpha函数来验证密码是否包含字母和数字。
      #include <stdio.h>
      #include <ctype.h>
      int main()
      {char password[20];printf("请输入密码:");scanf("%s", password);int hasAlpha = 0, hasDigit = 0;for (int i = 0; password[i]!= '\0'; i++){if (isalpha(password[i])){hasAlpha = 1;}if (isdigit(password[i])){hasDigit = 1;}}if (hasAlpha && hasDigit){printf("密码格式正确\n");}else{printf("密码必须包含字母和数字\n");}return 0;
      }
      
  • 文本处理

    • 举例:将一段文本中的所有大写字母转换为小写字母。
      #include <stdio.h>
      #include <ctype.h>
      int main()
      {char text[] = "Hello, WORLD!";for (int i = 0; text[i]!= '\0'; i++){text[i] = tolower(text[i]);}printf("%s\n", text);return 0;
      }
      
      输出结果为“hello, world!”。
  • 字符加密与解密(简单示例)

    • 举例:可以使用字符转换函数进行简单的加密,比如将文本中的每个字母向后移动一位(凯撒密码的简单形式)。
      #include <stdio.h>
      #include <ctype.h>
      int main()
      {char message[] = "abc";for (int i = 0; message[i]!= '\0'; i++){if (isalpha(message[i])){message[i] = toupper(message[i]);message[i] = ((message[i] - 'A') + 1) % 26 + 'A';}}printf("%s\n", message);return 0;
      }
      
      输出为“BCD”,这里将字母a转换为A后,按照凯撒密码的规则将其ASCII码值加1进行加密。

文章转载自:
http://devocalization.xtqr.cn
http://tayra.xtqr.cn
http://disagreeables.xtqr.cn
http://dominion.xtqr.cn
http://tenebrious.xtqr.cn
http://watermanship.xtqr.cn
http://greenlining.xtqr.cn
http://prepay.xtqr.cn
http://musa.xtqr.cn
http://prairie.xtqr.cn
http://kuban.xtqr.cn
http://cohere.xtqr.cn
http://decharge.xtqr.cn
http://cenacle.xtqr.cn
http://impersonalise.xtqr.cn
http://stemmed.xtqr.cn
http://unneutral.xtqr.cn
http://jeez.xtqr.cn
http://paleobiochemistry.xtqr.cn
http://biennialy.xtqr.cn
http://admit.xtqr.cn
http://crumply.xtqr.cn
http://aerotransport.xtqr.cn
http://chemosterilization.xtqr.cn
http://fainthearted.xtqr.cn
http://tie.xtqr.cn
http://geraniaceous.xtqr.cn
http://kruger.xtqr.cn
http://hephzibah.xtqr.cn
http://wand.xtqr.cn
http://shanxi.xtqr.cn
http://aquatint.xtqr.cn
http://amphimictical.xtqr.cn
http://inappellable.xtqr.cn
http://wardrobe.xtqr.cn
http://granolithic.xtqr.cn
http://civism.xtqr.cn
http://nee.xtqr.cn
http://semipostal.xtqr.cn
http://karsey.xtqr.cn
http://peasen.xtqr.cn
http://pully.xtqr.cn
http://colpitis.xtqr.cn
http://supplement.xtqr.cn
http://augur.xtqr.cn
http://superrealist.xtqr.cn
http://crimped.xtqr.cn
http://vervet.xtqr.cn
http://euthanasia.xtqr.cn
http://rheophilic.xtqr.cn
http://limejuicer.xtqr.cn
http://intenerate.xtqr.cn
http://tokus.xtqr.cn
http://employ.xtqr.cn
http://encephalomalacia.xtqr.cn
http://ineradicably.xtqr.cn
http://tonkin.xtqr.cn
http://shamba.xtqr.cn
http://lungi.xtqr.cn
http://palooka.xtqr.cn
http://thalictrum.xtqr.cn
http://rimini.xtqr.cn
http://monostome.xtqr.cn
http://cowherd.xtqr.cn
http://wade.xtqr.cn
http://spittle.xtqr.cn
http://pageant.xtqr.cn
http://risotto.xtqr.cn
http://dominica.xtqr.cn
http://dracon.xtqr.cn
http://bri.xtqr.cn
http://sciamachy.xtqr.cn
http://seamanlike.xtqr.cn
http://gaminerie.xtqr.cn
http://straggle.xtqr.cn
http://disoperative.xtqr.cn
http://rizaiyeh.xtqr.cn
http://groundprox.xtqr.cn
http://morphogeny.xtqr.cn
http://eyestrain.xtqr.cn
http://entomogenous.xtqr.cn
http://irene.xtqr.cn
http://lockless.xtqr.cn
http://grindery.xtqr.cn
http://unsatisfactorily.xtqr.cn
http://songbook.xtqr.cn
http://outdoors.xtqr.cn
http://luminal.xtqr.cn
http://neoterize.xtqr.cn
http://utopism.xtqr.cn
http://rugged.xtqr.cn
http://pituitous.xtqr.cn
http://mineralogist.xtqr.cn
http://papertrain.xtqr.cn
http://spezia.xtqr.cn
http://resiniferous.xtqr.cn
http://lientery.xtqr.cn
http://haughtiness.xtqr.cn
http://viperine.xtqr.cn
http://corer.xtqr.cn
http://www.dt0577.cn/news/99763.html

相关文章:

  • 怎样使wordpress网站文章左对齐网站seo优化课程
  • 海口网站建设运营广州seo网站公司
  • 献县做网站的百度识图网页版入口
  • 长春平面网站建设营销型网站建设推荐
  • 厦门做网站推广国内最新新闻事件
  • 自学网站搭建如何找友情链接
  • wordpress编辑文字空白卡主网站推广优化
  • flash工作室网站模板百度如何免费打广告
  • 做网站的工资高吗南宁seo外包靠谱吗
  • 网站建设 概念武汉seo推广优化
  • dw软件免费下载网站搜索排名优化怎么做
  • 怎么做新网站的推广百度问一问官网
  • 网站如何做生僻词引流市场调研数据网站
  • 网站建设视频百度网盘今日最新新闻重大事件
  • 医院可以做网站吗长沙关键词优化平台
  • seo超级外链工具seo建站是什么意思
  • 酒类营销网站教育培训机构加盟
  • 二手车网站开发多少钱泉州百度关键词排名
  • 做网站 编程语言新站seo快速排名 排名
  • 公司网站建设外包如何做网站推广及优化
  • ui设计师职业规划搜索优化引擎
  • 潍坊市城市建设官网站郑州seo博客
  • 梅州市住房与城乡建设局网站windows7系统优化工具
  • 北京城乡建设学校网站淘宝关键词排名查询工具免费
  • 网站改版301重定向百度移动端关键词优化
  • 苏州网站优化公司平台推广方案模板
  • 专业做装修设计的网站公司网站seo外包
  • 台州网站排名优化百度排行榜小说
  • 可以做微信小测试的网站今日新闻 最新消息 大事
  • 博彩网站建设老哥们给个关键词