#include <cctype>
检查
函数 | 重点 | 功能 |
---|
isalnum | 字母、数字 | Check if character is alphanumeric (function ) |
isdigit | 数字 | Check if character is decimal digit (function ) |
isalpha | 字母 | Check if character is alphabetic (function ) |
islower | 小写字母 | Check if character is lowercase letter (function ) |
isupper | 大写字母 | Check if character is uppercase letter (function ) |
isblank | | Check if character is blank (function ) |
iscntrl | | Check if character is a control character (function ) |
isgraph | | Check if character has graphical representation (function ) |
isprint | | Check if character is printable (function ) |
ispunct | | Check if character is a punctuation character (function ) |
isspace | | Check if character is a white-space (function ) |
isxdigit | | Check if character is hexadecimal digit (function ) |
string s = "AB34cd.?";
for(char ch:s)
{
cout << isalnum(ch) << " ";
}
转化
函数 | 重点 | 功能 |
---|
tolower | 大写变小写 | Convert uppercase letter to lowercase (function ) |
toupper | 小写变大写 | Convert lowercase letter to uppercase (function ) |
string s = "AB34cd.?";
for (int i = 0; i < s.size(); i++)
{
s[i] = tolower(s[i]);
}
cout << s << endl;