cctype函数 (字符类型判断)
这些函数都在cctype头文件定义
isalnum(c) 如果C是字母或数字,则为TRUE
isalpha(c) 如果C是字母,返回TRUE
iscntrl(c) 如果C是控制字符,返回TRUE
isdigit(c) 如果C是数字,返回TRUE
isgraph(c) 如果C不是空格,但可以打印,返回TRUE
islower(c) 如果C是小写,返回TRUE
isprint(c) 是可打印的,返回TRUE
ispunct(c) 如果C是标点字符,返回TRUE
isspace(c) 如果C是空白字符,返回TRUE
isupper(c) 如果是大写字符,返回TRUE
isxdigit(c) 如果C是16进制数,返回TRUE
tolower(c) 如果是大写,转化为小写
toupper(c)如果是小写,转化为大写
<span style="font-size:14px;">#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
string s="aeld2o";
for(string::size_type i=0;i<s.size();i++){
if(s[i]>'0'&&s[i]<'9'){
cout<<"有数字"<<endl;
break;
}
}
cout<<endl<<endl;
for(string::size_type i=0;i<s.length();i++){
if(isalnum(s[i])){
cout<<s[i]<<' ';
}
}
cout<<endl<<endl;
for(string::size_type j=0;j<s.size();j++){
if(isalpha(s[j])){
cout<<s[j]<<" ";
}
}
cout<<endl<<endl;
for(string::size_type z=0;z<s.size();z++){
if(isdigit(s[z])){
cout<<s[z]<<" ";
}
}
cout<<endl<<endl;
for(string::size_type k=0;k<s.size();k++){
if(isalpha(s[k])){
cout<<(char)toupper(s[k])<<" ";
}
}
cout<<endl;
return 0;
}</span>
cctype函数 (字符类型判断)的更多相关文章
- python的数据结构分类,以及数字的处理函数,类型判断
python的数据结构分类: 数值型 int:python3中都是长整形,没有大小限制,受限内存区域的大小 float:只有双精度型 complex:实数和虚数部分都是浮点型,1+1.2J bool: ...
- Python列表操作与深浅拷贝(5)——数字处理函数、类型判断、列表链表队列栈
python内建数据结构 分类 数值型: int float complex bool 序列对象: 字符串str 列表list 元组tuple 键值对: 集合set 字典dict 数值型 (list ...
- JS的数据类型判断函数、数组对象结构处理、日期转换函数,浏览器类型判断函数合集
工具地址:https://github.com/BothEyes1993/bes-jstools bes-jstools 100多个基础常用JS函数和各种数据转换处理集合大全,此工具包是在 outil ...
- python 类型判断-- isinstance函数
判断类型 函数isinstance()可以判断一个变量的类型,既可以用在Python内置的数据类型如str.list.dict,也可以用在我们自定义的类,它们本质上都是数据类型. 假设有如下的 Per ...
- js密码的校验(判断字符类型、统计字符类型个数)
/** *判断字符类型 */ function CharMode(iN) { if (iN >= 48 && iN <= 57) //数字 return 1; if (iN ...
- YUI的类型判断函数
1.首先定义一个关于类型的对象,及相关变量 类型判断对象 ar L = Y.Lang || (Y.Lang = {}), STRING_PROTO = String.prototype, TOSTRI ...
- Python判断输入字符类型
"""从键盘上输入 一个字符,判断其字符类型.""" while True: char = input("请输入需要判断的字符:& ...
- 类型和原生函数及类型转换(二:终结js类型判断)
typeof instanceof isArray() Object.prototype.toString.call() DOM对象与DOM集合对象的类型判断 一.typeof typeof是一个一元 ...
- 杂记-格式化Date默认格式,日期加一天,jstl判断字符类型,ajax模拟from表单后台跳转页面,jstl访问数据库并在页面显示
1.格式化Date默认格式 String str="Sun Oct 08 22:36:45 CST 2017"; SimpleDateFormat sdf = new Simple ...
随机推荐
- 【shiro】org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token
org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [org.apache.sh ...
- HTML5外包团队——技术分享:HTML5判断设备在线离线及监听网络状态变化例子
<!doctype html> <html> <head> <meta http-equiv="content-type" content ...
- HackerRank "Array and simple queries" !
The most interesting, flexible and juicy binary tree problem I have ever seen. I learnt it from here ...
- 【Redis】使用Redis Sentinel实现Redis HA
阅读目录 1 sentinel down-after-milliseconds mymaster 30000 sentinel failover-timeout mymaster 18000 sent ...
- Spring实战3:装配bean的进阶知识
主要内容: Environments and profiles Conditional bean declaration 处理自动装配的歧义 bean的作用域 The Spring Expressio ...
- WIN 8.1 x64 环境下 COM Surrogate 停止工作解决方案
我的笔记本电脑是THINKPAD T420 4180AT8,NVIDIA NVS 4200M,Intel(R) HD Graphics 3000,WIN 8.1 x64操作系统.在安装完NVIDIA独 ...
- VS使用技巧
1.VS帮助安装 VS2010为例==>注意,长时间未进行帮助安装,不过以下流程应该没有什么问题.如有问题,还请谅解... 2.VS即时窗口的应用 VS2010为例==>即时窗口的用法调试 ...
- 128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- Spring整合activiti-modeler5.16遇到的小问题
接上一篇整合activiti-modeler并成功创建model:Spring整合activiti-modeler5.16 之后,我尝试运用自定义的model部署流程,但是在部署的过程中又遇到了一 ...
- 技巧分享——如何去除多余的CSS代码?
有时候,当你的CSS代码过多的时候,而且已经明确知道有部分CSS代码是多余的: 这时候,有什么较快的办法可以去除多余的CSS呢?? 下面分享一个实用技巧: 1.使用谷歌浏览器:Chrome .下载 2 ...