转自:https://blog.csdn.net/wcl0617/article/details/79851797
C++标准库中提供了字符串大小写转换函数transform
,包含在头文件 #include <algorithm>
中。
1.小写转大写。
string strt = "aBc";
transform(strt.begin(), strt.end(), strt.begin(), ::toupper);
2.大写转小写。
string strt = "aBc";
transform(strt.begin(), strt.end(), strt.begin(), ::tolower);
需要包含头文件
#include <string>
#include <algorithm>