博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++ cctype定义的函数 - 学习笔记(7)
阅读量:6940 次
发布时间:2019-06-27

本文共 640 字,大约阅读时间需要 2 分钟。

这里一个简单的例子,查找出字符串中有几个标点符号。

代码如下:

#include 
using std::string; #include
using std::isupper; using std::toupper; using std::islower; using std::tolower; using std::isalpha; using std::isspace; #include
using std::cout; using std::endl; int main() {
string s("Hello world!!!"); string::size_type punct_cnt = 0; for(string::size_type index = 0; index != s.size(); ++index) if(ispunct(s[index])) ++punct_cnt; cout << punct_cnt << " punctuation characters in " << s << endl; return 0; }

 

运行截图:

参考:

转载于:https://www.cnblogs.com/andrew-blog/archive/2011/12/12/C_cctype.html

你可能感兴趣的文章
mysql主从延迟
查看>>
不在让你为你写代码头疼的链接页代码
查看>>
Vmware clone后,linux无法上网
查看>>
NetSuite crm国内合作商来讲讲NetSuite常见问题
查看>>
我的友情链接
查看>>
【原创】MySQL 实现Oracle或者PostgreSQL的row_number over 这样的排名语法
查看>>
Golang面试题解析(五)
查看>>
shell 输出100个+方法总结
查看>>
我的友情链接
查看>>
在启动kubernets的时候报错
查看>>
hive通过其它用户连接后执行语句提示没有hdfs系统目录权限
查看>>
ubuntu 配置网卡,DNS, iptables
查看>>
RT-Thread--内核基础
查看>>
BZOJ1434:[ZJOI2009]染色游戏(博弈论)
查看>>
[Python] Hermite 插值
查看>>
带头节点的单链表的插入操作优化
查看>>
winSockets编程(七)WSAAsyncSelect模式
查看>>
Huffman Codes
查看>>
求一棵二叉树的镜像
查看>>
Principal Component Analysis(PCA) algorithm summary
查看>>