加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c++primerplus书摘2(第五到八章)

发布时间:2020-12-16 07:19:07 所属栏目:百科 来源:网络整理
导读:1.字符函数 1 #includeiostream 2 #includecstdio 3 #includecstring 4 #includealgorithm 5 #includecctype 6 using namespace std; 7 /* 8 需要添加 #includecctype 9 isalnum() 如果参数是字母数字,即字母数字,该函数返回0否则为0 10 isalpha() 如果参

1.字符函数

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<cctype>
 6 using namespace std;
 7 /*
 8 需要添加 #include<cctype>
 9 isalnum() 如果参数是字母数字,即字母数字,该函数返回>0否则为0
10 isalpha() 如果参数是字母,该函数返回>0否则为0
11 iscntrl() 如果是控制字符,返回>0否则为0
12   控制字符是不可打印字符。可打印的字符是可以从键盘上输入的字符
13 第0~32号及第127号(共34个)是控制字符或通讯专用字符。
14 如控制符:LF(换行)、CR(回车)、FF(换页)、DEL(删除)、BS(退格)等
15 通讯专用字符:SOH(文头)、EOT(文尾)、ACK(确认)等
16 
17 isdigit() 如果参数是0~9,返回true
18 isgraph() 如果参数除空格以外的打印字符,返回>0否则为0
19 islower() 如果参数是小写字母,返回true
20 isprint() 如果参数是打印字符包括空格,返回true
21 ispunct() 如果参数是标点符号,返回true
22 isspace() 如果参数是标准空白字符,如空格、进纸、换行符、回车、水平制表符,返回true
23 isxdigit() 如果参数是十六进制数字,返回true
24 tolower() 如果参数是大写字符,则返回其小写,否则返回该参数
25 toupper() 如果参数是小写字符,则返回其大写,否则返回该参数
26 */
27 int main()
28 {
29    cout<<isalnum(+)<<" "<<isalnum(9)<<endl;
30    cout<<isalpha(a)<<" "<<isalpha(8)<<endl;
31    cout<<iscntrl()<<" "<<iscntrl(a)<<endl;
32    cout<<isdigit(a)<<" "<<isdigit(0)<<endl;
33    cout<<isgraph( )<<" "<<isgraph(1)<<" "<<isgraph(1)<<endl;
34    cout<<islower(a)<<" "<<islower(A)<<endl;
35    cout<<isxdigit(A)<<" "<<isxdigit(1)<<endl;
36    cout<<toupper(a)<<" "<<toupper(1)<<" "<<toupper(1)<<endl;
37    cout<<tolower(A)<<" "<<tolower(1)<<endl;
38     return 0;
39 }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读