cctype
~isalpha 字母(包括大写、小写)
~islower(小写字母)
~isupper(大写字母)
~isalnum(字母大写小写+数字)
~isblank(space和\t)
~isspace(space、\t、\r、\n)
-
tolower (->小写
-
toupper(->大写
以下是简单的cctype以及sort
#include<vector >
#include<algorithm>
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
bool cmp(int a,int b){
return a>b;//从大到小排序 ,似乎不允许 =
}
int main(){
vector<int> w(10);
for(int i=0;i<10;i++){
w.push_back(i+1);
}
cout<<endl;
sort(w.begin() ,w.end() ,cmp);
for(int i=0;i<10;i++){
cout<<w[i]<<" ";
}
if(isalnum('K')) printf("Y");//cctype 的 应用la~
else printf("N");
puts(" ");
char m='a';
printf("%c",toupper(m));//转为大写
}
to_string int,float之类 ->>string
#include<vector >
#include<algorithm>
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
int main(){
string ok,ko;
ok=to_string(123);//turn to字符
ko=to_string(45);
cout<<ok+ko<<endl;//两个字符串连接输出!
printf("%s",(ok+ko).c_str()); //printf 对应操作!
}
stoi stod ;
#include<vector >
#include<algorithm>
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
int main(){
string ok="123",ko="11.11";
int a;
double b;
a=stoi(ok);//string turn to int
b=stod(ko);//string turn to double
cout<<a<<" ";
cout<<b<<" ";
}
stold;
stoll;
stof;
stoul;