1 判断是否是二十六得字母中其中之一

   isalpha();

 #include <stdio.h>
#include <ctype.h>
#include <iostream>
using namespace std;
//是否是二十六个字母
int main()
{
int i = ;
char str[] = "C++";
while (str[i])
{
if (isalpha(str[i])) printf("character %c is alphabetic\n", str[i]);
else printf("character %c is not alphabetic\n", str[i]);
i++;
}
std::cin.get();
return ;
}

2 空白字符是用于在文本行内分隔单词的空格字符。

  isblank(int c)

 #include <stdio.h>
#include <ctype.h>
#include <iostream>
using namespace std;
//空白字符是用于在文本行内分隔单词的空格字符。
int main()
{
char c;
int i = ;
char str[] = "what are you from\n";
while (str[i])
{
c = str[i];
if (isblank(c)) c = '\n';
putchar(c);
i++;
}
cin.get();
return ; }

3 检查这个字符是否是控制字符

  int iscntrl(int c)

  (1) 一个控制字符是一个在显示上不占用打印位置的字符(这是一个可打印字符的反面,用isprint检查)

  (2)在标准c中ASCII的0x00-0x1f+0x7f

 #include <stdio.h>
#include <ctype.h>
#include <iostream>
using namespace std; //遇到一个终止字符就停止输出
int main()
{
int i = ;
char str[] = "first apple \n second apple \n";
while (!iscntrl(str[i]))
{
putchar(str[i]);
i++;
}
cin.get();
return ;
}

4 检查这个字符是否是十进制数字字符

  int isdigit(int c)

  0-9

 #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
using namespace std;
int main()
{
char str[] = "177667d";
//int year = atoi(str);
int year;
if (isdigit(str[]))
{
year = atoi(str);//只是会把数字部分留下
printf("The year that followed %d was %d.\n", year, year + );
}
cin.get();
return ;
}

5 检查字符是否是小写

int islower ( int c );
int toupper()转换为大写
 #include <stdio.h>
#include <ctype.h>
int main ()
{
int i=;
char str[]="Test String.\n";
char c;
while (str[i])
{
c=str[i];
if (islower(c)) c=toupper(c);
putchar (c);
i++;
}
return ;
}

6 检查字符是否可以打印(屏幕显示)

 #include <stdio.h>
#include <ctype.h>
#include <iostream>
using namespace std;
int main()
{
int i = ;
char str[] = "first line \n second line \n";
while (isprint(str[i]))
{
putchar(str[i]);
i++;
}
cin.get();
return ;
}

7 检查字符包含多少个标点符号

 #include <stdio.h>
#include <ctype.h>
#include <iostream>
using namespace std;
int main()
{
int i = ;
int cx = ;
char str[] = "Hello, welcome!";
while (str[i])
{
if (ispunct(str[i])) cx++;
i++;
}
printf("Sentence contains %d punctuation characters.\n", cx);
cin.get();
return ;
}

c++中ctype常用函数总结(isprint isblank..)的更多相关文章

  1. Mysql中的常用函数:

    Mysql中的常用函数: 1.字符串函数: (1).合并字符串 concat():// concat('M','y',"SQL",'5.5');== MySQL5.5//当传入的参 ...

  2. socket编程中客户端常用函数

    1 常用函数 1.1   connect() int connect(int sockfd, const struct sockaddr *servaddr, socklen_taddrlen); 客 ...

  3. numpy函数库中一些常用函数的记录

    ##numpy函数库中一些常用函数的记录 最近才开始接触Python,python中为我们提供了大量的库,不太熟悉,因此在<机器学习实战>的学习中,对遇到的一些函数的用法进行记录. (1) ...

  4. 日期时间函数 mysql 和sqlserver 中对于常用函数的日期和时间函数的区别

    1. sqlserver中获取时间用getdate(),默认返回格式是2019-01-21 13:58:33.053,具体的年月日,时分秒毫米,年月日之间用短线连接,时分秒之间用冒号连接,秒和毫米之间 ...

  5. C++中string常用函数用法总结

    string(s小写)是C++标准库中的类,纯C中没有,使用时需要包含头文件#include<string>,注意不是<string.h>,下面记录一下string中比较常用的 ...

  6. oracle中的常用函数、字符串函数、数值类型函数、日期函数,聚合函数。

    一.字符串的常用函数. --一.oracle 字符串常用函数 --1. concat 连接字符串的函数,只能连接[两个]字符串. 字符写在括号中,并用逗号隔开! --2."||"符 ...

  7. socket编程中客户端常用函数 以及简单实现

    1 常用函数 1.1   connect() int connect(int sockfd, const struct sockaddr *servaddr, socklen_taddrlen); 客 ...

  8. socket编程中服务器端常用函数 以及简单实现

    1 常用函数 1.1   socket() int socket(int family, int type, int protocol); socket()打开一个网络通讯端口,如果成功的话,返回一个 ...

  9. python中数据分析常用函数整理

    一. apply函数 作用:对 DataFrame 的某行/列应用函数之后,Apply 返回一些值.函数既可以使用默认的,也可以自定义.注意:在第二个输出中应用 head() 函数,因为它包含了很多行 ...

随机推荐

  1. Kristen Grauman

    http://www.cs.utexas.edu/~grauman/ CV         Publications         Code           Data        Short ...

  2. C# Winform 中webBrowser显示html内容时禁止错误提示的方法

    在winform中有一个控件可以显示html的内容,该控件就是webbrowser,设置它的DocumenText属性为HTML的内容即可. 在使用WebBrowser做UI的时候,我们有时不希望里面 ...

  3. 【caffe-windows】 caffe-master 之图片转换成lmdb or leveldb

    前期准备: 文件夹train:此文件夹中按类别分好子文件夹,各子文件夹里存放相应图片 文件夹test:同train,有多少类就有多少个子文件夹 trainlabels.txt : 存的是训练集的标签  ...

  4. NVIDIA GPU架构与原理分析(一)——GPU简介与主流Fermi、Kepler架构GPU概述

    1 GPU简介 图形处理单元GPU英文全称Graphic Processing Unit,GPU是相对于CPU的一个概念,NVIDIA公司在1999年发布GeForce256图形处理芯片时首先提出GP ...

  5. EasyDarwin添加自定义的服务模块EasyMyModule

    EasyDarwin模块的要求 每个QTSS模块必须实现两个方法函数: 一个Main入口函数,服务器在启动的时候将调用这个方法函数,来对您开发的模块所在的QTSS stub库进行初始化. 一个Disp ...

  6. 用EasyClient开源项目采集Windows摄像头/麦克风的音视频进行RTSP直播

    EasyClient是EasyDarwin开源流媒体团队开发的一款功能丰富的开源PC客户端项目,目前支持Windows.Android版本,后续将支持ios版本,其中Windows版本的EasyCli ...

  7. Colly provides a clean interface to write any kind of crawler/scraper/spider

    Scraping Framework for Golang http://go-colly.org/ https://github.com/gocolly/colly package main imp ...

  8. This means that only a small number of nodes must be read from disk to retrieve an item.

    http://cis.stvincent.edu/html/tutorials/swd/btree/btree.html Introduction A B-tree is a specialized ...

  9. Win10更新后,IE和Edge以外的浏览器打开网页速度慢的解决方案

    下载修复工具,提取码:you0 以管理员身份运行修复工具,点击“修复” 点击“确定” 提示“修复成功” 参考链接:Win10下极速模式无法打开网页的解决办法_360社区

  10. CentOS 6.9 安装 ftp 服务器

    昨天为了方便上传写好的博客 .md 文件到服务器上,就在服务器搭建了一个 ftp 服务端用来上传写好的博客.很久之前我也使用虚拟机搭建过 ftp 服务器,但是时间久了,很多都忘记了.于是乎又一顿 Go ...