C++ 内置函数 判断字母、数字及大小写转换

c++的几个内置函数

判断

islower(char c) :是否为小写字母
isupper(char c): 是否为大写字母
isdigit(char c) :是否为数字
isalpha(char c) :是否为字母
isalnum(char c): 是否为字母或者数字

转换

toupper(char c): 字母小转大
tolower(char c) :字母大转小

std 模板库的转换

string转换为其他类型

string转换为float: float stof(const string& str, size_t* idx = 0);
string转换为double: double stod(const string& str, size_t* idx = 0);
string转换为int: int stoi (const string& str, size_t* idx = 0, int base = 10);
string转换为long: long stol (const string& str, size_t* idx = 0, int base = 10);
string转换为long double: long double stold (const string& str, size_t* idx = 0);
string转换为long long: long long stoll (const string& str, size_t* idx = 0, int base = 10);
string转换为unsigned long: unsigned long stoul (const string& str, size_t* idx = 0, int base = 10);
string转换为unsigned long long: unsigned long long stoull (const string& str, size_t* idx = 0, int base = 10);

其他类型转换为string

string to_string (int val);
string to_string (long val);
string to_string (long long val);
string to_string (unsigned val);
string to_string (unsigned long val);
string to_string (unsigned long long val);
string to_string (float val);
string to_string (double val);
string to_string (long double val);

官网

原文链接: https://www.cnblogs.com/xiaohaigegede/p/13737237.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++ 内置函数 判断字母、数字及大小写转换

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/203302

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午9:27
下一篇 2023年2月12日 下午9:28

相关推荐