#include< cctype>
Today in the course of the brush in question, came across functions #include <cctype> in, hurried over to sum up inside commonly used functions.
<Cctype> C ++ Standard Library file header, this header file as the original <ctype.h> present in the C standard library. This is a process with many string function declaration header files, these functions can be used to separate strings and converting.
1、isdigit() :
Check character is a decimal number, for example: 0123456789.
2、islower() :
Check the character is a lowercase letter, for example: abcd
3、isupper():
Check the character is an uppercase letter, for example: ABCD
4、tolower() :
Converting uppercase to lowercase letters, for example: A> a.
5、toupper():
Lowercase letters are converted to upper case letters, for example: a> A.
(Subsequent updates)
In order to facilitate memory, to write a small Code:
code is as follows:
#include<iostream>
#include<cctype>
using namespace std;
int main()
{
char c;
while(cin>>c){
if(isdigit(c)){
cout<<"数字"<<endl;
}else if(islower(c)){
cout<<"小写"<<endl;
c=toupper(c);
cout<<"转换为大写"<<c<<endl;
}else if(isupper(c)){
cout<<"大写"<<endl;
c=tolower(c);
cout<<"转换为小写"<<c<<endl;
}else{
cout<<"不知道"<<endl;
}
}
return 0;
}