函式 |
說明 |
int isupper(char) |
判斷字元是否是大寫字母 |
int islower(char) |
判斷字元是否是小寫字母 |
int isalpha(char) |
判斷字元是否是字母 |
int isdigit(char) |
判斷字元是否是數字 |
int isalnum(char) |
判斷字元是否是字母或數字 |
int isspace(char) |
判斷字元是否是空白 |
int isblank(char) |
判斷字元是否是空格 |
int ispunct(char) |
判斷字元是否是標點符號 |
int isprint(char) |
判斷字元能否列印 |
int iscntrl(char) |
判斷字元是否是控制字元 |
int isgraph(char) |
判斷字元是否是圖形字元 |
int tolower(char) |
將字元轉換為小寫 |
int toupper(char) |
將字元轉換為大寫 |
#include <iostream>
#include "cctype"
int main() {
using std::cout;
char c{'A'};
cout << "A isupper:" << (isupper(c) ? "true" : "false") << char(10);
cout << "A islower:" << (islower(c) ? "true" : "false") << char(10);
cout << "A isalpha:" << (isalpha(c) ? "true" : "false") << char(10);
cout << "A isdigit:" << (isdigit(c) ? "true" : "false") << char(10);
cout << "A isalnum:" << (isalnum(c) ? "true" : "false") << char(10);
cout << "A isblank:" << (isblank(c) ? "true" : "false") << char(10);
cout << "A isalnum:" << (isalnum(c) ? "true" : "false") << char(10);
cout << "A ispunct:" << (ispunct(c) ? "true" : "false") << char(10);
cout << "A isprint:" << (isprint(c) ? "true" : "false") << char(10);
cout << "A iscntrl:" << (iscntrl(c) ? "true" : "false") << char(10);
cout << "A isgraph:" << (isgraph(c) ? "true" : "false") << char(10);
cout << "A tolower:" << char(tolower(c)) << char(10);
cout << "A toupper:" << char(toupper(c)) << char(10);
return 0;
}
A isupper:true
A islower:false
A isalpha:true
A isdigit:false
A isalnum:true
A isblank:false
A isalnum:true
A ispunct:false
A isprint:true
A iscntrl:false
A isgraph:true
A tolower:a
A toupper:A